Gets the namespace of this collection.
Aggregates documents according to the specified aggregation pipeline.
Stitch supports a subset of the available aggregation stages in MongoDB. See Unsupported Aggregation Stages.
the aggregation pipeline
a read operation which can be used to execute the aggregation
Counts the number of documents in the collection.
the query filter
the options describing the count
a Promise containing the number of documents in the collection
Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.
the query filter to apply the the delete operation
a Promise containing the result of the remove many operation
Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.
the query filter to apply the the delete operation
a Promise containing the result of the remove one operation
Finds all documents in the collection that match the given query.
An empty query ({}
) will match all documents.
the query filter
a read operation which can be used to execute the query
Finds one document in the collection that matches the given query.
An empty query ({}
) will match all documents.
the query filter
the resulting document or null if the query resulted in zero matches
Finds one document in the collection that matches the given query and deletes that document. (An empty query {} will match all documents)
A Document
that should match the query.
Optional: RemoteFindOneAndModifyOptions
to use when executing the command.
The DocumentT
being deleted or null if the query returned zero matches.
Finds one document in the collection that matches the given query and replaces that document with the given replacement. (An empty query {} will match all documents)
A Document
that should match the query.
A Document
that will replace the matched document
Optional: RemoteFindOneAndModifyOptions
to use when executing the command.
A resulting DocumentT
or null if the query returned zero matches.
Finds one document in the collection that matches the given query and performs the given update on that document. (An empty query {} will match all documents)
A Document
that should match the query.
A Document
describing the update.
Optional: RemoteFindOneAndModifyOptions
to use when executing the command.
A resulting DocumentT
or null if the query returned zero matches.
Inserts one or more documents.
the documents to insert
a Promise containing the result of the insert many operation
Inserts the provided document. If the document is missing an identifier, the client should generate one.
the document to insert
a Promise containing the result of the insert one operation
Update all documents in the collection according to the specified arguments.
a document describing the query filter, which may not be null.
a document describing the update, which may not be null. The update to apply must include only update operators.
the options to apply to the update operation
a Promise containing the result of the update many operation
Update a single document in the collection according to the specified arguments.
a document describing the query filter, which may not be null.
a document describing the update, which may not be null. The update to apply must include only update operators.
the options to apply to the update operation
a Promise containing the result of the update one operation
Opens a MongoDB change stream against the collection to watch for changes. You can watch a subset of the documents in the collection by passing an array of specific document ids or a match expression that filters the ChangeEvents from the change stream.
Defining the match expression to filter ChangeEvents is similar to defining the match expression for triggers.
Optional. An array of ids to watch or a $match expression filter. Omit to watch the entire collection.
a Promise containing a stream of change events representing the changes to the watched documents.
Opens a MongoDB change stream against the collection to watch for changes made to specific documents. The documents to watch must be explicitly specified by their _id.
Requests a stream where the full document of update events, and several other unnecessary fields are omitted from the change event objects returned by the server. This can save on network usage when watching large documents.
This method does not support opening change streams on an entire collection or a specific query.
the _ids of the documents to watch in this change stream
a Promise containing a stream of compact change events representing the changes to the watched documents.
Create a new RemoteMongoCollection instance with a different default class to cast any documents returned from the database into.
the default class to cast any documents returned from the database into.
a new CoreRemoteMongoCollection instance with the different default class
Generated using TypeDoc
RemoteMongoCollection
The RemoteMongoCollection is the interface to a MongoDB database's collection via Stitch, allowing read and write.
It is retrieved from a RemoteMongoDatabase.
The read operations are find, count and aggregate.
The write operations are insertOne, insertMany, updateOne, updateMany, deleteOne, and deleteMany.
If you are already familiar with MongoDB drivers, it is important to understand that the RemoteMongoCollection only provides access to the operations available in Stitch. For a list of unsupported aggregation stages, see Unsupported Aggregation Stages.
Note
Log in first
A user will need to be logged in (at least anonymously) before you can read from or write to the collection. See StitchAuth.
Example
// Get the existing Stitch client. const stitchClient = Stitch.defaultAppClient // Get a client of the Remote Mongo Service for database access const mongoClient = stitchClient.getServiceClient(RemoteMongoClient.factory, 'mongodb-atlas') // Retrieve a database object const db = mongoClient.db('video') // Retrieve the collection in the database const movieDetails = db.collection('movieDetails') // Find 10 documents and log them to console. movieDetails.find({}, {limit: 10}) .toArray() .then(results => console.log('Results:', results))
See Also