odata-query-sql
Converts odata query to sql query.
INSTALL
npm i -S odata-query-sql
USAGE
var odataQuerySql = ;var result = ;
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 = ;var oquery = $count: true $filter: "name eq 'Ivan'" ;var options = resource: "user" dialect: "mysql" );var result = ;// result.count: "select count(*) from user where name = 'Ivan'"// result.value: "select * from user where name = 'Ivan' limit 50"
var odataQuerySql = ;var oquery = $expand: "category" $filter: "title eq 'moby dick'" $select: "title";var options = resource: "book" dialect: "mysql" var result = ;// 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