Skip to content

routier-collection


routier-collection / plugins/mongodb/src / MongoDriver

Interface: MongoDriver ​

Defined in: plugins/mongodb/src/driver.ts:51

Properties ​

name ​

readonly name: string

Defined in: plugins/mongodb/src/driver.ts:53

Names the engine, for errors that would otherwise not say which one failed.

Methods ​

collection() ​

collection(name): Promise<MongoCollection>

Defined in: plugins/mongodb/src/driver.ts:54

Parameters ​

name ​

string

Returns ​

Promise<MongoCollection>


transaction() ​

transaction<T>(work): Promise<T>

Defined in: plugins/mongodb/src/driver.ts:68

Runs work exactly once, atomically, and returns what it returned.

Exactly once is part of the contract, not an accident of the implementation. Mongo's withTransaction helper retries on a transient error and on a commit conflict, and a driver that used it would make this the only backend in the repository that silently repeats a save — SQLite lets SQLITE_BUSY abort, and the same code has to fail the same way everywhere. A driver retries nothing; a conflict reaches the caller.

A driver whose engine cannot offer atomicity — a standalone mongod rejects transactions outright — may run work with an unbound scope, but it has to say so when it is constructed rather than at the first save.

Type Parameters ​

T ​

T

Parameters ​

work ​

(scope) => Promise<T>

Returns ​

Promise<T>


dropDatabase() ​

dropDatabase(): Promise<void>

Defined in: plugins/mongodb/src/driver.ts:70

Removes the database. Succeeds when it does not exist.

Returns ​

Promise<void>


close() ​

close(): Promise<void>

Defined in: plugins/mongodb/src/driver.ts:71

Returns ​

Promise<void>

Released under the MIT License.