Support of AWS DocumentDB for .NET

CAST supports Amazon DocumentDB via its com.castsoftware.nosqldotnetexternal link extension. As Amazon DocumentDB is MongoDB compatible, supported operations, objects and links are identical to those listed 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:

ObjectType of Property ValuePossible Value(s)Meaning
DotNet MongoDB collectionInteger1The collection object is of type Amazon DocumentDB
DotNet MongoDB collectionInteger0The collection object is of type MongoDB
DotNet unknown MongoDB collectionInteger1The collection object is of type Amazon DocumentDB
DotNet unknown MongoDB collectionInteger0The collection object is of type MongoDB

What results can you expect?

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.

Known Limitations

  • Setting of properties related to Amazon DocumentDB identification depends on proper resolution of connection string.