// Get the logged-in Stitch clientconst 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))
RemoteMongoDatabase
RemoteMongoDatabase provides access to a MongoDB database.
It is instantiated by RemoteMongoClient.
Once instantiated, it can be used to access a RemoteMongoCollection for reading and writing data.
Example
// Get the logged-in 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