For Backbone.js devs: easily enable new Cloud based experiences in your apps with the Windows Azure Mobile Data Service

For Backbone.js devs: easily enable new Cloud based experiences in your apps with the Windows Azure Mobile Data Service

Rate This
  • Comments 0

Synchronizing data with the cloud has just become easier for Backbone.js developers thanks to the open source Backbone adapter for Windows Azure Mobile Data Service from Microsoft Open Technologies, Inc. Developers using the popular JavaScript framework Backbone.JS to structure their web apps now only need to add a couple values indicating the table name and location to offer their customers brand new experiences leveraging the cloud.

About Windows Azure Mobile Services

With Windows Azure Mobile Services, you can streamline common development tasks like structuring storage, integrating push notifications and configuring user authentication. Mobile Services fully supports Windows Store, Windows Phone 8, iOS, and Android development and are free for your first ten apps. The data service provides a straightforward way to store structured data in the cloud.

The Backbone adapter for Windows Azure Mobile Data Service

The Backbone adapter that MS Open Tech open sourced is for HTML apps. It overrides the backbone.sync method to make things work seamlessly with Backbone applications. Using the adapter is as simple as including a JavaScript file (in addition to the JavaScript file from the Windows Azure Mobile Data Service HTML library) in your Backbone application. Since the backbone.sync method is overrode, all restful calls to the server are intercepted and converted to the format that works with the Windows Azure Mobile Data Service.

How about some code?

A sample backbone collection would look like the following:

var People = Backbone.Collection.extend({
    client: client,
    table: 'Table1',
    model: Person
});

var people  = new People();
var employee = people.create(data);
people.fetch(conditions);

As shown in the example above, the only additional parameters that need to be added to the collection are:

  • ‘table’: indicating the corresponding table where the collection must be saved on Azure
  • ‘client’: this client object corresponds to the WindowsAzure.MobileServiceClient and typically helps with authentication when writing data to the database.

All other operations such as create, update and fetch are like the usual Backbone operations.

The fetch operation can also take additional parameters to filter the required data to bring it to the browser. The options for filter can specify a ‘skip’, a ‘take’, or a ‘where’ clause. For detailed information, check out the README.md file.

Call to action

To get started with Windows Azure Mobile Services, check out the Windows Azure portal.

You can find the Backbone adapter for Windows Azure Mobile Services project on our GitHub page.

Please let us know what you think commenting on this post or in the project, and do not hesitate to point us to your great web apps using Windows Azure Mobile Services!

Leave a Comment
  • Please add 3 and 1 and type the answer here:
  • Post
  • Loading...