MCPcopy
hub / github.com/mongodb/node-mongodb-native / db

Method db

src/mongo_client.ts:830–846  ·  view source on GitHub ↗

* Create a new Db instance sharing the current socket connections. * * @param dbName - The name of the database we want to use. If not provided, use database name from connection string. * @param options - Optional settings for Db construction

(dbName?: string, options?: DbOptions)

Source from the content-addressed store, hash-verified

828 * @param options - Optional settings for Db construction
829 */
830 db(dbName?: string, options?: DbOptions): Db {
831 options = options ?? {};
832
833 // Default to db from connection string if not provided
834 if (!dbName) {
835 dbName = this.s.options.dbName;
836 }
837
838 // Copy the options and add out internal override of the not shared flag
839 const finalOptions = Object.assign({}, this.options, options);
840
841 // Return the db object
842 const db = new Db(this, dbName, finalOptions);
843
844 // Return the database
845 return db;
846 }
847
848 /**
849 * Creates a new MongoClient instance and immediately connects it to MongoDB.

Callers 15

testConfigBeforeHookFunction · 0.95
makeConnectionTestFunction · 0.95
testConnectionFunction · 0.95
runFunction · 0.95
testPushWithIdFunction · 0.95
testAggregateFunction · 0.95
testFindOneAndUpdateFunction · 0.95
testBulkWriteFunction · 0.95
runMethod · 0.95
scheduleWorkloadFunction · 0.45
scheduleWriteWorkloadFunction · 0.45
createDataKeyMethod · 0.45

Calls

no outgoing calls

Tested by 7

makeConnectionTestFunction · 0.76
testConnectionFunction · 0.76
runFunction · 0.76
testAggregateFunction · 0.76
testFindOneAndUpdateFunction · 0.76
testBulkWriteFunction · 0.76
runMethod · 0.76