0.5.0 • Published 10 years ago

caql-js-compiler v0.5.0

Weekly downloads
10
License
MIT
Repository
github
Last release
10 years ago

caql-js-compiler

Compile CaQL queries into executable JavaScript.

Learn more: Calypso Query Language (CaQL) Specification.

Install

npm install caql-js-compiler

Example

var JSCompiler = require('caql-js-compiler');

var entries = [
  { name: 'Postini', founded_year: 1999, total_money_raised: '$0' },
  { name: 'Digg', founded_year: 2004, total_money_raised: '$45M' },
  { name: 'Airbnb', founded_year: 2007, total_money_raised: '$120M' },
  { name: 'TripIt', founded_year: 2006, total_money_raised: '$13.1M' },
  { name: 'Twitter', founded_year: 2006, total_money_raised: '$1.16B' },
  { name: 'Spotify', founded_year: 2006, total_money_raised: '$183M' },
  { name: 'Airbnb', founded_year: 2008, total_money_raised: '$776.4M' }
];

var compiler = new JSCompiler();

var query =   'select name, founded_year, total_money_raised as worth '
            + 'where founded_year >= 1999 and name not like "%air%" '
            + 'order by founded_year desc, name';

compiler
  .compile(query)
  .execute(entries)
  .forEach(function(result) {
    console.log(result);
  });

// Output:
//
//    { name: 'Spotify', founded_year: 2006, worth: '$183M' }
//    { name: 'TripIt', founded_year: 2006, worth: '$13.1M' }
//    { name: 'Twitter', founded_year: 2006, worth: '$1.16B' }
//    { name: 'Digg', founded_year: 2004, worth: '$45M' }
//    { name: 'Postini', founded_year: 1999, worth: '$0' }

License

MIT

0.5.0

10 years ago

0.4.0

10 years ago

0.3.0

11 years ago

0.2.0

11 years ago

0.1.0

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago