Class MongoCollectionExtensions
Extension methods for MongoDB.Driver.IMongoCollection<TDocument>.
public static class MongoCollectionExtensions
- Inheritance
-
MongoCollectionExtensions
- Inherited Members
Methods
FindByIdAsync<T, TId>(IMongoCollection<T>, TId)
Find a single document based on Id - asynchronous.
public static Task<T?> FindByIdAsync<T, TId>(this IMongoCollection<T> collection, TId id)
Parameters
collectionIMongoCollection<T>MongoDB.Driver.IMongoCollection<TDocument> to extend.
idTIdId of document.
Returns
- Task<T>
The document if found, default if not.
Type Parameters
TType of document.
TIdType of identifier.
FindById<T, TId>(IMongoCollection<T>, TId)
Find a single document based on Id.
public static T? FindById<T, TId>(this IMongoCollection<T> collection, TId id)
Parameters
collectionIMongoCollection<T>MongoDB.Driver.IMongoCollection<TDocument> to extend.
idTIdId of document.
Returns
- T
The document if found, default if not.
Type Parameters
TType of document.
TIdType of identifier.
ObserveById<TDocument, TId>(IMongoCollection<TDocument>, TId)
Create an observable query that will observe a single document based on Id of the document in the collection for changes matching the filter criteria.
public static ISubject<TDocument> ObserveById<TDocument, TId>(this IMongoCollection<TDocument> collection, TId id)
Parameters
collectionIMongoCollection<TDocument>MongoDB.Driver.IMongoCollection<TDocument> to extend.
idTIdThe identifier of the document to observe.
Returns
- ISubject<TDocument>
Async Task holding System.Reactive.Subjects.Subject<T> with an instance of the type.
Type Parameters
TDocumentType of document in the collection.
TIdType of id - key.
ObserveSingle<TDocument>(IMongoCollection<TDocument>, FilterDefinition<TDocument>?, FindOptions?)
Create an observable query that will observe the collection for changes matching the filter criteria.
public static ISubject<TDocument> ObserveSingle<TDocument>(this IMongoCollection<TDocument> collection, FilterDefinition<TDocument>? filter = null, FindOptions? options = null)
Parameters
collectionIMongoCollection<TDocument>MongoDB.Driver.IMongoCollection<TDocument> to extend.
filterFilterDefinition<TDocument>Optional filter.
optionsFindOptionsOptional options.
Returns
- ISubject<TDocument>
Async Task holding System.Reactive.Subjects.Subject<T> with a collection of the type for the collection.
Type Parameters
TDocumentType of document in the collection.
ObserveSingle<TDocument>(IMongoCollection<TDocument>, Expression<Func<TDocument, bool>>?, FindOptions?)
Create an observable query that will observe the collection for changes matching the filter criteria.
public static ISubject<TDocument> ObserveSingle<TDocument>(this IMongoCollection<TDocument> collection, Expression<Func<TDocument, bool>>? filter, FindOptions? options = null)
Parameters
collectionIMongoCollection<TDocument>MongoDB.Driver.IMongoCollection<TDocument> to extend.
filterExpression<Func<TDocument, bool>>Optional filter.
optionsFindOptionsOptional options.
Returns
- ISubject<TDocument>
Async Task holding System.Reactive.Subjects.Subject<T> with a collection of the type for the collection.
Type Parameters
TDocumentType of document in the collection.
Observe<TDocument>(IMongoCollection<TDocument>, FilterDefinition<TDocument>?, FindOptions?)
Create an observable query that will observe the collection for changes matching the filter criteria.
public static ISubject<IEnumerable<TDocument>> Observe<TDocument>(this IMongoCollection<TDocument> collection, FilterDefinition<TDocument>? filter = null, FindOptions? options = null)
Parameters
collectionIMongoCollection<TDocument>MongoDB.Driver.IMongoCollection<TDocument> to extend.
filterFilterDefinition<TDocument>Optional filter.
optionsFindOptionsOptional options.
Returns
- ISubject<IEnumerable<TDocument>>
Async Task holding System.Reactive.Subjects.Subject<T> with a collection of the type for the collection.
Type Parameters
TDocumentType of document in the collection.
Observe<TDocument>(IMongoCollection<TDocument>, Expression<Func<TDocument, bool>>?, FindOptions?)
Create an observable query that will observe the collection for changes matching the filter criteria.
public static ISubject<IEnumerable<TDocument>> Observe<TDocument>(this IMongoCollection<TDocument> collection, Expression<Func<TDocument, bool>>? filter, FindOptions? options = null)
Parameters
collectionIMongoCollection<TDocument>MongoDB.Driver.IMongoCollection<TDocument> to extend.
filterExpression<Func<TDocument, bool>>Optional filter.
optionsFindOptionsOptional options.
Returns
- ISubject<IEnumerable<TDocument>>
Async Task holding System.Reactive.Subjects.Subject<T> with a collection of the type for the collection.
Type Parameters
TDocumentType of document in the collection.