On this page本页内容
Session
()¶New in version 3.6.版本3.6中的新功能。
The Session object for the connection in the mongo
shell. mongo
shell中连接的会话对象。To instantiate a session for the connection in the 要在mongo
shell, see Mongo.startSession()
. mongo
shell中为连接实例化会话,请参阅Mongo.startSession()
。For more information on sessions, see Client Sessions and Causal Consistency Guarantees.有关会话的更多信息,请参阅客户端会话和因果一致性保证。
Session. getDatabase (<database>)¶ |
mongo shell.mongo shell中的会话访问指定的数据库。 |
Session. advanceClusterTime ({ clusterTime: <timestamp>, signature: { hash: <BinData>, keyId: <NumberLong> } })¶ |
|
Session. advanceOperationTime (<timestamp>)¶ |
|
Session. endSession ()¶ |
|
Session. hasEnded ()¶ |
|
Session. getClusterTime ()¶ |
|
Session. getOperationTime ()¶ |
|
Session. getOptions ()¶ |
SessionOptions .SessionOptions 。 |
Session.startTransaction() |
Session.startTransaction() .Session.startTransaction() 。 |
Session.commitTransaction() |
Session.commitTransaction() .Session.commitTransaction() 。 |
Session.abortTransaction() |
Session.abortTransaction() .Session.abortTransaction() 。 |
The following example starts a session on the 以下示例在与Mongo
connection object associated with the mongo
shell’s global db
variable, and then uses the Session.getDatabase()
method to retrieve the database object associated with the session.mongo
shell的全局db变量关联的Mongo connection对象上启动一个会话,然后使用Session.getDatabase()
方法检索与该会话关联的数据库对象。