Code Monkey home page Code Monkey logo

documentdbcpp's Introduction

DocumentDBCpp

Introduction

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. Library works with both Windows (both VS2013 and VS2015) and Linux, on both x86 and x64. There is also associated Nuget you can use.

Usage

Perfect article to get you started is here. Some sample code as a teaser:

	// Start by defining your account's configuration
	DocumentDBConfiguration conf (U("https://<account>.documents.azure.com"), U("<primary_key>"));
	// Create your client
	DocumentClient client (conf);
	// Create a new database
	shared_ptr<Database> db = client.CreateDatabase (U("db"));
	// Create a collection inside database
	shared_ptr<Collection> coll = db->CreateCollection (U("coll"));
	// Insert a document
	web::json::value doc;
	doc[U("foo")] = web::json::value::string (U("bar"));
	coll->CreateDocument (doc);
	// All of the above is also supported in async fashion
	coll->CreateDocumentAsync (doc).then ([=](shared_ptr<Document> doc)
	{
		ucout << U("Asynchronously done inserting document");
	});

For complete set of supported methods, look at test.cpp and/or browse a code.

Installation

Windows

Installing this library is easiest with Nuget that you can find here. If you get stuck, detailed explanation is here.

Linux

There is no support for Linux installation out-of-box, you will have to compile library yourself (take a look below).

Compiling

Windows

Only VS compiler is supported on Windows. There are two solutions - one for VS2013 (toolset v120) and one for VS2015 (toolset v140). Pick one you would like, fire it and build.

Linux

There are no other dependencies, once you compile and install C++ REST SDK. To compile and install C++ REST SDK, refer to this article. Once you are done, start by cloning, creating build directory and configuring it:

git clone https://github.com/stalker314314/DocumentDBCpp.git DocumentDBCpp
mkdir docdb.build
cd docdb.build
cmake ../DocumentDBCpp

After that, compile and install as usual:

make
sudo make install

There is nothing magical about this process, this is regular CMake. If you want to use some IDE, let's say Eclipse, configure like this:

cmake -G "Eclipse CDT4 - Unix Makefiles" ../DocumentDBCpp

If you want to build, for example, Debug version without tests and sample, you can configure with something like this:

cmake -DBUILD_TESTS=OFF -DBUILD_SAMPLES=OFF -DCMAKE_BUILD_TYPE=Debug ../DocumentDBCpp

Testing

Test your new changes by running documentdbtest. Couple of notes before you fire it up:

  1. No support currently for proper unit testing
  2. Note that you will have to put your own account in test.cpp on which tests will be run against
  3. There is no automatic cleanup if tests are failing, so you will need to clean up after yourself
  4. Tests are not accessing other databases in your account, nor deleting anything, but anyway...be careful

Backlog

  1. Extend object model with users, triggers, UDFs, conflicts and the rest of supported DocumentDB entities
  2. Support for TCP protocol
  3. Support working with secondary keys

documentdbcpp's People

Contributors

stalker314314 avatar vustef avatar asthana86 avatar gurudennis avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.