Instance Propertyswift-mongodb 0.27.0MongoDriver->Mongo
preconditionTime
The minimum operation time that subsequent operations using this session presume. Every command run on a session updates the precondition time in order to provide a guarantee of causal consistency.
Mongo.Session.swift:41var preconditionTime: BSON.Timestamp? { get }
This is simply a long-winded way of saying that time never moves backward when running commands on a session.
Other members in extension
Type members
init(from: Mongo.SessionPool, by: ContinuousClock.Instant?
) async throws Creates a session from a session pool. Do not escape the session from the scope that yielded the pool, because doing so will prevent the pool from draining on scope exit.
Instance members
let id: SessionIdentifier
var transaction: TransactionState
The current transaction state of this session.
func fork(by: ContinuousClock.Instant?
) async throws -> Self Forks this session, returning a new session. Operations on the newly-created session will reflect writes performed using the original session at the time of session creation, but the two sessions will be otherwise unrelated.
func refresh(on: Mongo.ReadPreference
) async throws Runs a
RefreshSessions
command. Calling this convenience method is equivalent to constructing aRefreshSessions
instance with this session’sid
and running it manually.func run<Command>(command: Command, against: Command.Database, on: Mongo.ReadPreference, by: ContinuousClock.Instant?
) async throws -> Command.Response Runs a command against the specified database, on a server selected according to the specified read preference.
func run<Query, Success>(command: Query, against: Query.Database, on: Mongo.ReadPreference, by: ContinuousClock.Instant?, with: (Mongo.Cursor<Query.Element>) async throws -> Success
) async throws -> Success Runs an iterable command against the specified database, on a server selected according to the specified read preference.
func synchronize(to: BSON.Timestamp
) Similar to
synchronize(with:)
, but accepts aBSON.Timestamp
instead of a full session instance. This is useful for synchronizing sessions across concurrency domains, as sessions themselves are non-Sendable
.func synchronize(with: Mongo.Session
) Fast-forwards this session’s precondition time to the other session’s precondition time, if it is non-nil and greater than this session’s precondition time. The other session’s precondition time is unaffected.
func withSnapshotTransaction<Success>(writeConcern: Mongo.WriteConcern?, run: (Mongo.Transaction) async throws -> Success
) async -> Mongo.TransactionResult<Success> func withTransaction<Success>(writeConcern: Mongo.WriteConcern?, readConcern: Mongo.ReadConcern?, run: (Mongo.Transaction) async throws -> Success
) async -> Mongo.TransactionResult<Success> Yields a transaction context that can be used to run commands with this session as part of a transaction. If the closure parameter throws an error, the transaction will be aborted, otherwise it will be committed.