Table of Contents

Interface IMongoDbRepositoryBase<TDocument>

Namespace
Excalibur.Data.MongoDB
Assembly
Excalibur.Data.MongoDB.dll

Provides base repository functionality for interacting with MongoDB for a specific document type.

public interface IMongoDbRepositoryBase<TDocument> where TDocument : class

Type Parameters

TDocument

The type of the document to manage in MongoDB.

Methods

AddOrUpdateAsync(string, TDocument, CancellationToken)

Adds or updates a document in the MongoDB collection.

Task<bool> AddOrUpdateAsync(string documentId, TDocument document, CancellationToken cancellationToken)

Parameters

documentId string

The unique identifier for the document.

document TDocument

The document to be added or updated.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<bool>

true if the operation was acknowledged.

GetByIdAsync(string, CancellationToken)

Retrieves a document from MongoDB by its ID.

Task<TDocument?> GetByIdAsync(string documentId, CancellationToken cancellationToken)

Parameters

documentId string

The unique identifier of the document.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<TDocument>

The document if found, or null if not found.

RemoveAsync(string, CancellationToken)

Removes a document from the MongoDB collection.

Task<bool> RemoveAsync(string documentId, CancellationToken cancellationToken)

Parameters

documentId string

The unique identifier of the document to remove.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<bool>

true if the document was removed; false if not found.