Page tree
Skip to end of metadata
Go to start of metadata

CAST supports Amazon DocumentDB via its NoSQL for .NET extension. As Amazon DocumentDB is MongoDB compatible, supported operations, objects and links are identical to that in MongoDB.

Supported Amazon DocumentDB versions

VersionSupported
4.0(tick)
3.6(tick)

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

DotNet MongoDB collectionIs an Amazon DocumentDB collection?Integer

1



The collection object is of type Amazon DocumentDB

0The collection object is of type MongoDB
DotNet unknown MongoDB collectionIs an Amazon DocumentDB collection?Integer

1



The collection object is of type Amazon DocumentDB

0The collection object is of type MongoDB

What results can you expect?

Sample Code
class Program
    {
       static void Main(string[] args)
        {
           string template = "mongodb://{0}:{1}@{2}/?replicaSet=rs0&readpreference={3}";
           string username = "root";
           string password = "rootroot";
           string clusterEndpoint = "sample-cluster.cluster-cqjaxx9hbhi0.us-west-2.docdb.amazonaws.com:27017";
           string readPreference = "secondaryPreferred";

           string connectionString = String.Format(template, username, password, clusterEndpoint, readPreference);
           var settings = MongoClientSettings.FromUrl(new MongoUrl(connectionString));
           var client = new MongoClient(settings);

           var database = client.GetDatabase("library");
           var collection = database.GetCollection<BsonDocument>("Books");

           var docToInsert = new BsonDocument { { "title", "Harry Potter" } };
           collection.InsertOne(docToInsert);
        }
    }

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.

  • No labels