odata-query-sql

0.0.1 • Public • Published

odata-query-sql

Converts odata query to sql query.

INSTALL

npm i -S odata-query-sql

USAGE

var odataQuerySql = require("odata-query-sql");
var result = odataQuerySql(oquery, options);

API

  • oquery odata query object ($select, $filter, etc.)
  • options.dialect type of sql driver (mysql, sqlite)
  • options.resource requested resource name (table)
  • options.defaultLimit limit should be set (min = 1, max = 500, default = 50)

EXAMPLES

var odataQuerySql = require("odata-query-sql");
var oquery = { $count: true, $filter: "name eq 'Ivan'", };
var options = { resource: "user", dialect: "mysql" });
var result = odataQuerySql(oquery, options);
// result.count: "select count(*) from user where name = 'Ivan'"
// result.value: "select * from user where name = 'Ivan' limit 50"
var odataQuerySql = require("odata-query-sql");
var oquery = { $expand: "category", $filter: "title eq 'moby dick'", $select: "title"};
var options = { resource: "book", dialect: "mysql" }
var result = odataQuerySql(oquery, options);
// result.value: "select * from book where title = 'moby dick' limit 50"
// result.expand.category: 
// "select * from category where id in (select category_id from book where title = 'moby dick')"

CHANGELOG

  • 0.0.1 (15 Aug 2016) first release

/odata-query-sql/

    Package Sidebar

    Install

    npm i odata-query-sql

    Weekly Downloads

    4

    Version

    0.0.1

    License

    Xnet

    Last publish

    Collaborators

    • iamthes