CAST supports Amazon DocumentDB via its NoSQL for Java extension. As Amazon DocumentDB is MongoDB compatible, supported operations, objects and links are identical to that in MongoDB.
Supported Amazon DocumentDB versions
Version | Supported |
---|---|
4.0 | |
3.6 |
Amazon DocumentDB Identification
The below mentioned objects in MongoDB have properties to indicate whether the object is of type MongoDB or Amazon DocumentDB:
Object | Property Description | Type of Property Value | Possible Value(s) | Meaning |
---|---|---|---|---|
Java MongoDB collection | Is an Amazon DocumentDB collection? | Integer | 1 | The collection object is of type Amazon DocumentDB |
0 | The collection object is of type MongoDB | |||
Java unknown MongoDB collection | Is an Amazon DocumentDB collection? | Integer | 1 | The collection object is of type Amazon DocumentDB |
0 | The collection object is of type MongoDB |
What results can you expect?
Sample Code
package com.sample.app; import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; import com.mongodb.ServerAddress; import com.mongodb.MongoException; import com.mongodb.client.MongoCursor; import com.mongodb.client.MongoDatabase; import com.mongodb.client.MongoCollection; import org.bson.Document; public final class App { private App() { } public static void main(String[] args) { String connectionString = "mongodb://root:rootroot@sample-cluster.cluster-cqjaxx9hbhi0.us-west-2.docdb.amazonaws.com:27017/?replicaSet=rs0&readpreference=secondaryPreferred"; MongoClientURI clientURI = new MongoClientURI(connectionString); MongoClient mongoClient = new MongoClient(clientURI); MongoDatabase testDB = mongoClient.getDatabase("library"); MongoCollection<Document> numbersCollection = testDB.getCollection("books"); Document doc = new Document("name", "title").append("value", "Harry Potter"); numbersCollection.insertOne(doc); MongoCursor<Document> cursor = numbersCollection.find().iterator(); try { while (cursor.hasNext()) { System.out.println(cursor.next().toJson()); } } finally { cursor.close(); } } }
For detailed information on results related to objects and links see MongoDB.
Limitations
Setting of properties related to Amazon DocumentDB identification depends on proper resolution of connection string.