DocumentDBCpp is C++ wrapper and object model for DocumentDB NoSQL database. It is built on top of C++ REST SDK framework, so all the goodies like Task Parallelism are included. There is no other dependencies except C++ REST SDK.
// Start by defining your account's configuration
DocumentDBConfiguration conf (L"https://<account>.documents.azure.com", L"<primary_key>");
// Create your client
DocumentClient client (conf);
// Create a new database
shared_ptr<Database> db = client.CreateDatabase (L"db");
// Create a collection inside database
shared_ptr<Collection> coll = db->CreateCollection (L"coll");
// Insert a document
web::json::value doc;
doc[L"foo"] = web::json::value::string (L"bar");
coll->CreateDocument (doc);
// All of the above is also supported in async fashion
coll->CreateDocumentAsync (doc).then ([=](shared_ptr<Document> doc)
{
wcout << L"Asynchronously done inserting document";
});
For complete set of supported methods, look at test.cpp and/or browse a code.
Test your new changes by running Test.exe. Couple of notes before you fire it up:
- No support currently for proper unit testing
- Note that you will have to put your own account in test.cpp on which tests will be run against
- There is no automatic cleanup if tests are failing, so you will need to clean up after yourself
- Tests are not accessing other databases in your account, nor deleting anything, but anyway...be careful
- Extend object model with users, triggers, UDFs, conflicts and the rest of supported DocumentDB entities
- Support for TCP protocol
- Support working with secondary keys
- Support Linux and all other platforms where C++ REST SDK is supported
- Support x64
- Support v140 toolset