Interface RemoteMongoDatabase
-
- All Known Implementing Classes:
RemoteMongoDatabaseImpl
public interface RemoteMongoDatabase
The RemoteMongoDatabase interface provides access to itsRemoteMongoCollection
s.In order to obtain an instance of the database, use
RemoteMongoClient.getDatabase(java.lang.String)
.Once you have a database, you can use
getCollection(java.lang.String)
to get a collection to start reading and writing documents.- See Also:
RemoteMongoClient
,RemoteMongoCollection
-
-
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()); });
-
-
-
Method Summary
Modifier and Type Method Description RemoteMongoCollection<Document>
getCollection(String collectionName)
Gets aRemoteMongoCollection
.<DocumentT>
RemoteMongoCollection<DocumentT>getCollection(String collectionName, Class<DocumentT> documentClass)
Gets a collection, with a specific default document class.String
getName()
Gets the name of the database.
-
-
-
Method Detail
-
getName
String getName()
Gets the name of the database.- Returns:
- the database name
-
getCollection
RemoteMongoCollection<Document> getCollection(String collectionName)
Gets aRemoteMongoCollection
.- Parameters:
collectionName
- the name of the collection to return- Returns:
- the collection
-
getCollection
<DocumentT> RemoteMongoCollection<DocumentT> getCollection(String collectionName, Class<DocumentT> documentClass)
Gets a collection, with a specific default document class.- Type Parameters:
DocumentT
- the type of the class to use instead ofDocument
.- Parameters:
collectionName
- the name of the collection to returndocumentClass
- the default class to cast any documents returned from the database into.- Returns:
- the collection
-
-