Search Results for

    Show / Hide Table of Contents

    Class MongoClient.Collection<TDocument>

    An object representing a remote MongoDB collection.

    Inheritance
    Object
    MongoClient.Collection<TDocument>
    Namespace: Realms.Sync
    Assembly: Realm.dll
    Syntax
    public class Collection<TDocument>
        where TDocument : class
    Type Parameters
    Name Description
    TDocument

    The managed type that matches the shape of the documents in the collection.

    Properties

    | Improve this Doc View Source

    Database

    Gets the Database this collection belongs to.

    Declaration
    public MongoClient.Database Database { get; }
    Property Value
    Type Description
    MongoClient.Database

    The collection's Database.

    | Improve this Doc View Source

    Name

    Gets the name of the collection.

    Declaration
    public string Name { get; }
    Property Value
    Type Description
    String

    The collection name.

    Methods

    | Improve this Doc View Source

    AggregateAsync(Object[])

    Executes an aggregation pipeline on the collection and returns the results as a MongoDB.Bson.BsonDocument array.

    Declaration
    public Task<BsonDocument[]> AggregateAsync(params object[] pipeline)
    Parameters
    Type Name Description
    Object[] pipeline

    Documents describing the different pipeline stages using pipeline expressions.

    Returns
    Type Description
    Task<MongoDB.Bson.BsonDocument[]>

    An awaitable Task representing the remote aggregate operation. The result of the task is an array containing the documents returned by executing the aggregation pipeline.

    See Also
    https://docs.mongodb.com/manual/aggregation/
    | Improve this Doc View Source

    AggregateAsync<TProjection>(Object[])

    Executes an aggregation pipeline on the collection and returns the results as a TProjection array.

    Declaration
    public Task<TProjection[]> AggregateAsync<TProjection>(params object[] pipeline)
    Parameters
    Type Name Description
    Object[] pipeline

    Documents describing the different pipeline stages using pipeline expressions.

    Returns
    Type Description
    Task<TProjection[]>

    An awaitable Task representing the remote aggregate operation. The result of the task is an array containing the documents returned by executing the aggregation pipeline.

    Type Parameters
    Name Description
    TProjection

    The managed type that matches the shape of the result of the pipeline.

    See Also
    https://docs.mongodb.com/manual/aggregation/
    | Improve this Doc View Source

    CountAsync(Object, Nullable<Int64>)

    Counts the number of documents in the collection that match the provided filter.

    Declaration
    public Task<long> CountAsync(object filter = null, long? limit = default(long? ))
    Parameters
    Type Name Description
    Object filter

    A document describing the find criteria using query operators. If not specified, all documents in the collection will be counted.

    Nullable<Int64> limit

    The maximum number of documents to count. If not specified, all documents in the collection are counted.

    Returns
    Type Description
    Task<Int64>

    An awaitable Task representing the remote count operation. The result of the task is the number of documents that match the filter and limit criteria.

    | Improve this Doc View Source

    DeleteManyAsync(Object)

    Removes one or more documents from a collection. If no documents match the filter, the collection is not modified.

    Declaration
    public Task<MongoClient.DeleteResult> DeleteManyAsync(object filter = null)
    Parameters
    Type Name Description
    Object filter

    A document describing the deletion criteria using query operators. If not specified, all documents in the collection will be deleted.

    Returns
    Type Description
    Task<MongoClient.DeleteResult>

    An awaitable Task<TResult> representing the remote delete many operation. The result of the task contains the number of deleted documents.

    See Also
    https://docs.mongodb.com/manual/reference/method/db.collection.deleteMany/
    | Improve this Doc View Source

    DeleteOneAsync(Object)

    Removes a single document from a collection. If no documents match the filter, the collection is not modified.

    Declaration
    public Task<MongoClient.DeleteResult> DeleteOneAsync(object filter = null)
    Parameters
    Type Name Description
    Object filter

    A document describing the deletion criteria using query operators. If not specified, the first document in the collection will be deleted.

    Returns
    Type Description
    Task<MongoClient.DeleteResult>

    An awaitable Task<TResult> representing the remote delete one operation. The result of the task contains the number of deleted documents.

    See Also
    https://docs.mongodb.com/manual/reference/method/db.collection.deleteOne/
    | Improve this Doc View Source

    FindAsync(Object, Object, Object, Nullable<Int64>)

    Finds the all documents in the collection up to limit.

    Declaration
    public Task<TDocument[]> FindAsync(object filter = null, object sort = null, object projection = null, long? limit = default(long? ))
    Parameters
    Type Name Description
    Object filter

    A document describing the find criteria using query operators. If not specified, all documents in the collection will be returned.

    Object sort

    A document describing the sort criteria. If not specified, the order of the returned documents is not guaranteed.

    Object projection

    A document describing the fields to return for all matching documents. If not specified, all fields are returned.

    Nullable<Int64> limit

    The maximum number of documents to return. If not specified, all documents in the collection are returned.

    Returns
    Type Description
    Task<TDocument[]>

    An awaitable Task representing the remote find operation. The result of the task is an array containing the documents that match the find criteria.

    See Also
    https://docs.mongodb.com/manual/reference/method/db.collection.find/
    | Improve this Doc View Source

    FindOneAndDeleteAsync(Object, Object, Object)

    Finds the first document in the collection that satisfies the query criteria.

    Declaration
    public Task<TDocument> FindOneAndDeleteAsync(object filter = null, object sort = null, object projection = null)
    Parameters
    Type Name Description
    Object filter

    A document describing the find criteria using query operators. If not specified, all documents in the collection will match the request.

    Object sort

    A document describing the sort criteria. If not specified, the order of the returned documents is not guaranteed.

    Object projection

    A document describing the fields to return for all matching documents. If not specified, all fields are returned.

    Returns
    Type Description
    Task<TDocument>

    An awaitable Task<TResult> representing the remote find one operation. The result of the task is the first document that matches the find criteria.

    See Also
    https://docs.mongodb.com/manual/reference/method/db.collection.findOneAndDelete/
    | Improve this Doc View Source

    FindOneAndReplaceAsync(Object, TDocument, Object, Object, Boolean, Boolean)

    Finds the first document in the collection that satisfies the query criteria.

    Declaration
    public async Task<TDocument> FindOneAndReplaceAsync(object filter, TDocument replacementDoc, object sort = null, object projection = null, bool upsert = false, bool returnNewDocument = false)
    Parameters
    Type Name Description
    Object filter

    A document describing the find criteria using query operators. If not specified, all documents in the collection will match the request.

    TDocument replacementDoc

    The replacement document. Cannot contain update operator expressions.

    Object sort

    A document describing the sort criteria. If not specified, the order of the returned documents is not guaranteed.

    Object projection

    A document describing the fields to return for all matching documents. If not specified, all fields are returned.

    Boolean upsert

    A boolean controlling whether the replace should insert a document if no documents match the filter. Defaults to false.
    MongoDB will add the _id field to the replacement document if it is not specified in either the filter or replacement documents. If _id is present in both, the values must be equal.

    Boolean returnNewDocument

    A boolean controlling whether to return the replacement document. If set to false the original document before the update is returned. Defaults to false.

    Returns
    Type Description
    Task<TDocument>

    An awaitable Task<TResult> representing the remote find one operation. The result of the task is the first document that matches the find criteria.

    See Also
    https://docs.mongodb.com/manual/reference/method/db.collection.findOneAndReplace/
    | Improve this Doc View Source

    FindOneAndUpdateAsync(Object, Object, Object, Object, Boolean, Boolean)

    Finds the first document in the collection that satisfies the query criteria.

    Declaration
    public async Task<TDocument> FindOneAndUpdateAsync(object filter, object updateDocument, object sort = null, object projection = null, bool upsert = false, bool returnNewDocument = false)
    Parameters
    Type Name Description
    Object filter

    A document describing the find criteria using query operators. If not specified, all documents in the collection will match the request.

    Object updateDocument

    A document describing the update. Can only contain update operator expressions.

    Object sort

    A document describing the sort criteria. If not specified, the order of the returned documents is not guaranteed.

    Object projection

    A document describing the fields to return for all matching documents. If not specified, all fields are returned.

    Boolean upsert

    A boolean controlling whether the update should insert a document if no documents match the filter. Defaults to false.

    Boolean returnNewDocument

    A boolean controlling whether to return the new updated document. If set to false the original document before the update is returned. Defaults to false.

    Returns
    Type Description
    Task<TDocument>

    An awaitable Task<TResult> representing the remote find one operation. The result of the task is the first document that matches the find criteria.

    See Also
    https://docs.mongodb.com/manual/reference/method/db.collection.findOneAndUpdate/
    | Improve this Doc View Source

    FindOneAsync(Object, Object, Object)

    Finds the first document in the collection that satisfies the query criteria.

    Declaration
    public Task<TDocument> FindOneAsync(object filter = null, object sort = null, object projection = null)
    Parameters
    Type Name Description
    Object filter

    A document describing the find criteria using query operators. If not specified, all documents in the collection will match the request.

    Object sort

    A document describing the sort criteria. If not specified, the order of the returned documents is not guaranteed.

    Object projection

    A document describing the fields to return for all matching documents. If not specified, all fields are returned.

    Returns
    Type Description
    Task<TDocument>

    An awaitable Task<TResult> representing the remote find one operation. The result of the task is the first document that matches the find criteria.

    See Also
    https://docs.mongodb.com/manual/reference/method/db.collection.findOne/
    | Improve this Doc View Source

    InsertManyAsync(IEnumerable<TDocument>)

    Inserts one or more documents in the collection.

    Declaration
    public async Task<MongoClient.InsertManyResult> InsertManyAsync(IEnumerable<TDocument> docs)
    Parameters
    Type Name Description
    IEnumerable<TDocument> docs

    The documents to insert.

    Returns
    Type Description
    Task<MongoClient.InsertManyResult>

    An awaitable Task<TResult> representing the remote insert many operation. The result of the task contains the _ids of the inserted documents.

    See Also
    https://docs.mongodb.com/manual/reference/method/db.collection.insertMany/
    | Improve this Doc View Source

    InsertOneAsync(TDocument)

    Inserts the provided document in the collection.

    Declaration
    public async Task<MongoClient.InsertResult> InsertOneAsync(TDocument doc)
    Parameters
    Type Name Description
    TDocument doc

    The document to insert.

    Returns
    Type Description
    Task<MongoClient.InsertResult>

    An awaitable Task<TResult> representing the remote insert operation. The result of the task contains the _id of the inserted document.

    See Also
    https://docs.mongodb.com/manual/reference/method/db.collection.insertOne/
    | Improve this Doc View Source

    UpdateManyAsync(Object, Object, Boolean)

    Updates one or more documents in the collection according to the specified arguments.

    Declaration
    public async Task<MongoClient.UpdateResult> UpdateManyAsync(object filter, object updateDocument, bool upsert = false)
    Parameters
    Type Name Description
    Object filter

    A document describing the selection criteria of the update. If not specified, all documents in the collection will be updated. Can only contain query selector expressions.

    Object updateDocument

    A document describing the update. Can only contain update operator expressions.

    Boolean upsert

    A boolean controlling whether the update should insert a document if no documents match the filter. Defaults to false.

    Returns
    Type Description
    Task<MongoClient.UpdateResult>

    An awaitable Task<TResult> representing the remote update many operation. The result of the task contains information about the number of matched and updated documents, as well as the _id of the upserted document if upsert was set to true and the operation resulted in an upsert.

    See Also
    https://docs.mongodb.com/manual/reference/method/db.collection.updateMany/
    | Improve this Doc View Source

    UpdateOneAsync(Object, Object, Boolean)

    Updates a single document in the collection according to the specified arguments.

    Declaration
    public async Task<MongoClient.UpdateResult> UpdateOneAsync(object filter, object updateDocument, bool upsert = false)
    Parameters
    Type Name Description
    Object filter

    A document describing the selection criteria of the update. If not specified, the first document in the collection will be updated. Can only contain query selector expressions.

    Object updateDocument

    A document describing the update. Can only contain update operator expressions.

    Boolean upsert

    A boolean controlling whether the update should insert a document if no documents match the filter. Defaults to false.

    Returns
    Type Description
    Task<MongoClient.UpdateResult>

    An awaitable Task<TResult> representing the remote update one operation. The result of the task contains information about the number of matched and updated documents, as well as the _id of the upserted document if upsert was set to true and the operation resulted in an upsert.

    See Also
    https://docs.mongodb.com/manual/reference/method/db.collection.updateOne/
    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2020 Realm
    Generated by DocFX