Interface RemoteMongoClient
-
- All Known Implementing Classes:
RemoteMongoClientImpl
public interface RemoteMongoClient
The RemoteMongoClient is the entry point for working with data in MongoDB remotely via Stitch.An instance can be retrieved using
StitchAppClient.getServiceClient(com.mongodb.stitch.android.core.services.internal.NamedServiceClientFactory<T>, java.lang.String)
with this class'sfactory
.Before using the database, you will have to log in using
StitchAuth
.Once logged in, you can access the database with
getDatabase(java.lang.String)
.- See Also:
StitchAppClient
,StitchAuth
,RemoteMongoDatabase
-
-
Example
// Find 20 documents in a collection // Note: log in first -- see StitchAuth RemoteMongoClient mongoClient = appClient.getServiceClient(RemoteMongoClient.factory, "mongodb-atlas"); RemoteMongoDatabase db = mongoClient.getDatabase("video"); RemoteMongoCollection<Document> movieDetails = db.getCollection("movieDetails"); movieDetails.find().limit(20).forEach(document -> { Log.i(TAG, "Got document: " + document.toString()); });
-
-
-
Field Summary
Fields Modifier and Type Field Description static NamedServiceClientFactory<RemoteMongoClient>
factory
-
Method Summary
Modifier and Type Method Description RemoteMongoDatabase
getDatabase(String databaseName)
Gets aRemoteMongoDatabase
instance for the given database name.
-
-
-
Field Detail
-
factory
static final NamedServiceClientFactory<RemoteMongoClient> factory
-
-
Method Detail
-
getDatabase
RemoteMongoDatabase getDatabase(String databaseName)
Gets aRemoteMongoDatabase
instance for the given database name.- Parameters:
databaseName
- the name of the database to retrieve- Returns:
- a
RemoteMongoDatabase
representing the specified database
-
-