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
collection
IMongoCollection<T>MongoDB.Driver.IMongoCollection<TDocument> to extend.
id
TIdId of document.
Returns
- Task<T>
The document if found, default if not.
Type Parameters
T
Type of document.
TId
Type 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
collection
IMongoCollection<T>MongoDB.Driver.IMongoCollection<TDocument> to extend.
id
TIdId of document.
Returns
- T
The document if found, default if not.
Type Parameters
T
Type of document.
TId
Type 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
collection
IMongoCollection<TDocument>MongoDB.Driver.IMongoCollection<TDocument> to extend.
id
TIdThe 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
TDocument
Type of document in the collection.
TId
Type 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
collection
IMongoCollection<TDocument>MongoDB.Driver.IMongoCollection<TDocument> to extend.
filter
FilterDefinition<TDocument>Optional filter.
options
FindOptionsOptional options.
Returns
- ISubject<TDocument>
Async Task holding System.Reactive.Subjects.Subject<T> with a collection of the type for the collection.
Type Parameters
TDocument
Type 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
collection
IMongoCollection<TDocument>MongoDB.Driver.IMongoCollection<TDocument> to extend.
filter
Expression<Func<TDocument, bool>>Optional filter.
options
FindOptionsOptional options.
Returns
- ISubject<TDocument>
Async Task holding System.Reactive.Subjects.Subject<T> with a collection of the type for the collection.
Type Parameters
TDocument
Type 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
collection
IMongoCollection<TDocument>MongoDB.Driver.IMongoCollection<TDocument> to extend.
filter
FilterDefinition<TDocument>Optional filter.
options
FindOptionsOptional options.
Returns
- ISubject<IEnumerable<TDocument>>
Async Task holding System.Reactive.Subjects.Subject<T> with a collection of the type for the collection.
Type Parameters
TDocument
Type 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
collection
IMongoCollection<TDocument>MongoDB.Driver.IMongoCollection<TDocument> to extend.
filter
Expression<Func<TDocument, bool>>Optional filter.
options
FindOptionsOptional options.
Returns
- ISubject<IEnumerable<TDocument>>
Async Task holding System.Reactive.Subjects.Subject<T> with a collection of the type for the collection.
Type Parameters
TDocument
Type of document in the collection.