/** * @method DatabasePool.register * @static * @description * - Registers each database object, to make sure no duplicates connections are used, * and if they are, produce a warning; * - Registers each Pool object, to be able to release them all when requested. * * @param {Database} db - The new Database object being registered. */ static register(db) { const cnKey = DatabasePool.createContextKey(db); npm.utils.addReadProp(db, `$cnKey`, cnKey, true); if (cnKey in DatabasePool.dbMap) { DatabasePool.dbMap[cnKey]++; /* istanbul ignore if */ if (!db.$config.options.noWarnings) { ColorConsole.warn(`WARNING: Creating a duplicate database object for the same connection.\n${npm.utils.getLocalStack(4, 3)}\n`); } } else { DatabasePool.dbMap[cnKey] = 1; } DatabasePool.dbs.push(db); }