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

Method startSession

src/mongo_client.ts:894–906  ·  view source on GitHub ↗

* Creates a new ClientSession. When using the returned session in an operation * a corresponding ServerSession will be created. * * @remarks * A ClientSession instance may only be passed to operations being performed on the same * MongoClient it was started from.

(options?: ClientSessionOptions)

Source from the content-addressed store, hash-verified

892 * MongoClient it was started from.
893 */
894 startSession(options?: ClientSessionOptions): ClientSession {
895 const session = new ClientSession(
896 this,
897 this.s.sessionPool,
898 { explicit: true, ...options },
899 this.options
900 );
901 this.s.activeSessions.add(session);
902 session.once('ended', () => {
903 this.s.activeSessions.delete(session);
904 });
905 return session;
906 }
907
908 /**
909 * A convenience method for creating and handling the clean up of a ClientSession.

Callers 15

withSessionMethod · 0.95
createEntitiesMethod · 0.80
runTestSuiteTestFunction · 0.80
sessions.test.tsFile · 0.80
testFunction · 0.80
testFunction · 0.80
crud.prose.test.tsFile · 0.80

Calls 3

addMethod · 0.80
onceMethod · 0.80
deleteMethod · 0.45

Tested by 2

testFunction · 0.64
testFunction · 0.64