// Assumption: Stitch is already logged in.// Get the existing Stitch client.const stitchClient = Stitch.defaultAppClient
// Get a client of the Remote Mongo Service for database accessconst mongoClient = stitchClient.getServiceClient(RemoteMongoClient.factory, 'mongodb-atlas')
// Retrieve a database objectconst db = mongoClient.db('video')
// Retrieve the collection in the databaseconst movieDetails = db.collection('movieDetails')
// Find 10 documents and log them to console.
movieDetails.find({}, {limit: 10})
.toArray()
.then(results =>console.log('Results:', results))
RemoteMongoReadOperation
Represents a
find
oraggregate
operation against a RemoteMongoCollection.The methods in this class execute the operation and retrieve the results, either as an iterator or all in one array with toArray.
Example
// Assumption: Stitch is already logged in. // 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