The type of the entities managed by the connector. Should extend MongoEntity
.
Constructs a new instance of the class.
The name of the collection to be associated with the instance.
Creates a new document in the specified collection with the provided data.
The name of the collection where the data will be inserted.
The data object to be added to the collection.
A promise that resolves to the inserted data including the generated ID and timestamps.
Deletes a document from the specified collection by its identifier.
The name of the collection from which the document will be deleted.
The identifier of the document to be deleted.
A promise resolving to true if the document was successfully deleted, false otherwise.
Retrieves all documents from a given collection that match the specified query and parameters.
The name of the database collection to search.
A string defining the filter conditions, separated by "AND" clauses and using "=" for key-value matching.
An array of values to be matched against the keys defined in the query.
A promise that resolves to an array of documents matching the query conditions.
Fetches a single record from the specified collection that matches the given query and parameters.
The name of the collection to query.
The query string to execute against the collection.
The parameters to bind to the query.
A promise that resolves to the first matching record or null
if no match is found.
Retrieves all documents from a specified collection.
The name of the collection to retrieve documents from.
A promise that resolves to an array of documents of type T.
Retrieves a single document from the specified collection based on its unique identifier.
The name of the collection to query.
The unique identifier of the document to retrieve.
A promise that resolves to the document matching the given identifier.
Initializes a MongoDB connection using environment variables or default values. The connection is established with authentication and logged on successful connection.
A promise that resolves when the MongoDB connection is successfully established.
This method is called when the component or object is being destroyed. It is typically used for cleanup operations, such as unsubscribing from observables, detaching event listeners, or releasing resources.
Does not return any value.
Updates a document in the specified collection with the provided data. Converts the data into a document format, applies a modified timestamp, and updates the corresponding record in the database.
The name of the collection where the update should occur.
The data object to update, which will be converted into a document.
Returns the updated document if the update is successful,
or null
if no document is modified. In case of an error, returns the error object.
Provides a generic MongoDB connector implementation for managing collections and documents. This class handles CRUD operations, transforms data between application and MongoDB formats, and establishes a connection to the MongoDB instance.