MongoDBDriver
Creates a new MongoDBDriver.
Parameters
Name | Description |
---|---|
config | Connection configuration options. |
MongoDBPreparedStatement
Parameters
Name | Description |
---|---|
driver | The MongoDBDriver instance. |
operation | The operation directive string. |
MongoDBDriver
MongoDB driver implementation. Handles connection, queries, and MongoDB-specific operations.
MongoDBPreparedStatement
MongoDBPreparedStatement wraps a MongoDBDriver operation for deferred execution.
connect
Establishes a connection to MongoDB. Builds the URI, configures the client, and selects the database.
returns
— Promise<void>
disconnect
Closes the MongoDB connection and clears the reference.
returns
— Promise<void>
query
Executes a MongoDB operation encoded as a string directive. Parses collection, method, and parameters, then dispatches the call.
Parameters
Name | Description |
---|---|
operation | Directive in the format "collection:method". |
params | Parameters object or payload for the operation. |
returns
— Promise<QueryResult>
prepare
Prepares a MongoDB operation for later execution. MongoDB does not support parameterized statements natively, so this wraps the operation directive in a PreparedStatement.
Parameters
Name | Description |
---|---|
operation | The operation directive string. |
returns
— Promise<PreparedStatement>
beginTransaction
Begins a transaction context. MongoDB transactions require a replica set or sharded cluster.
returns
— Promise<void>
commit
Commits the current transaction context.
returns
— Promise<void>
rollback
Rolls back the current transaction context.
returns
— Promise<void>
getLastInsertId
Retrieves the last inserted document ID. For MongoDB, this is included in the result of insert operations.
returns
— Promise<string | number>
escape
Escapes a value for inclusion in logging or introspection. MongoDB uses JSON, so this serializes the value.
Parameters
Name | Description |
---|---|
value | Any JavaScript value. |
returns
— A JSON-stringified representation.
getGrammar
Returns the grammar instance for query compilation.
returns
— MongoDBGrammar
supportsFeature
Determines if the driver supports a given feature.
Parameters
Name | Description |
---|---|
feature | The feature name to check. |
returns
— boolean
buildConnectionUri
Builds the MongoDB connection URI.
returns
— The MongoDB connection string.
getCollection
Returns the MongoDB collection instance by name.
Parameters
Name | Description |
---|---|
name | Collection name. |
returns
— Collection
createIndex
Creates an index on a collection.
Parameters
Name | Description |
---|---|
collection | Collection name. |
keys | Index specification object. |
options | Optional index options. |
returns
— Promise<void>
dropIndex
Drops an index from a collection.
Parameters
Name | Description |
---|---|
collection | Collection name. |
indexName | Name of the index to drop. |
returns
— Promise<void>
execute
Executes the prepared operation with given parameters.
Parameters
Name | Description |
---|---|
params | Parameters for the operation payload. |
returns
— Promise<QueryResult>
close
Closes the prepared statement. MongoDB does not require explicit cleanup.
returns
— Promise<void>