Overview

Cloud Data Connector is a javascript library intended to ease the pain of working with services data sources. CDC is built with TypeScript, and provide TypeScript definition.

It supports offline mode and can handle all CRUD operations for you.


CDC is built with a provider system, so that you could plug your own services. For now, CDC has a provider for Azure Mobile Services, Amazon Web Services, Azure Table Storage, Azure Queue Storage, CouchDB, Restful and a few experimental providers on Facebook, Twitter, etc.

How to get the project

You can get it from GitHub, or download the latest version.


Building your own version

Compiled files are available in the "dist" folder, but if you want to deep dive into the source code, or make changes, you could make your own setup.


Install Node Package Manager (NPM)

You will need NodeJS and NPM to compile sources. If you don't have it yet, download NPM latest package.


Install Grunt

From the command line, install grunt client globally with


npm install -g grunt-cli

It will download the grunt task runner and other required plugins.


Install dependencies

Set the command line to the directory where you put the sources, like "C:\myprojects\"

Now we will install the required dependencies with :


npm install

It will download the grunt task runner and other plugins used to build CDC like :

  • ts-compiler, the TypeScript compiler
  • grunt-typescript to wrap TypeScript compilation into a grunt module
  • grunt-contrib-watch to provide live compilation of TypeScript files


Launch Grunt

You are all set ! Just run the grunt task by running the command :


grunt

It will run the "gruntfile.js" and compile all into "dist" folder.


Compile on the fly

The grunt script also defines a watcher task. It will compile your TypeScript files on the fly whenever you make changes to sources.

To activate the watcher, simply run the "watch" target with the command :


grunt watch

Samples


To use CDC On WinJS/React/Polymer you need to add the references to the cdc.js file and the Azure provider API in the head of your page, as well as a reference to the Azure Mobile Services client library.


<script src="[path]/cdc.js"></script>
<script src="[path]/cdc-azuremobileservices.js"></script>
<script src="https://ajax.aspnetcdn.com/ajax/mobileservices/MobileServices.Web-1.1.0.min.js"></script>

Init the CDC service and Azure Data Service


var cdcAzureMobileService = new CloudDataConnector.AzureDataService();
var CDCService = new CloudDataConnector.DataService(new CloudDataConnector.OfflineService(), new CloudDataConnector.ConnectivityService());
//configure url, appkey and your tableName
cdcAzureMobileService.addSource('https://angularpeoplev2.azure-mobile.net/', 
                                        'DDJpBYxoQEUznagCnyYNRYfkDxpYyz90',  
                                        ['people']);     
CDCService.addSource(cdcAzureMobileService);

You are ready ! You can now perform add, change, delete requests, after calling connect function


CDCService.connect(function (results) {
        if (results === false) {
                throw "CDCService must first be successfully initialized";
        }
        else {
            // We are good to go
        }
}, dataContext, onUpdateDataContext, 3);

Go to this section to get informations about how to use cdc with AngularJs