Microsoft is continuing to build on it’s cloud based document database designed for web applications and today is announcing support for JavaScript Language Integrated Queries.

Azure DocumentDB’s database engine is purposefully designed from the ground up to provide first class support for JSON and JavaScript. Our vision is for JavaScript developers to build applications without having to deal with the entity mappers, schemas, code generation tools, type adornments and other duct tapes.  — Azure Blog

Azure DocumentDB allows developers to store data in native JSON format and then perform queries on that data including using stored procedures.  The diagram below shows how JSON data is stored in Azure DocumentDB



The query for all “exports” from documents with the headquarters of Belgium previously looked like this.

function() {
 var filterQuery = 'SELECT * from companies c where c.headquarter = "Belgium"';
 var isAccepted = <strong>.queryDocuments(</strong>.getSelfLink(), filterQuery,
 function(err, docs, options) {
 if (err) throw new Error(err.number + err.message);
 if (!isAccepted) __.response.setBody('Query timed out');

But with JavaScript Language Integrated Queries, that same query can be expressed with this syntax.

function() {
 var resp = __.filter(function(company) {
 return company.headquarter == 'Belgium';
 if (!resp.isAccepted) __.response.setBody('Query timed out');

For more information on this announcement including a SQL to JavaScript Query API Cheat Sheet, visit the Azure Blog.