This repository has been archived by the owner on Feb 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
BASE.query.SqlVisitor
Jared Barnes edited this page Sep 8, 2015
·
1 revision
Queryables hold expression trees. From the expression trees you can use Visitor's to output the queryable into that language. The example below is the SqlVisitor.
BASE.require([ "BASE.query.Queryable", "BASE.query.SqlVisitor" ], function(){ var SqlVisitor= BASE.query.SqlVisitor; var Queryable = BASE.query.Queryable; var queryable = new Queryable().where(function(expressionBuilder){ return expressionBuilder.property("firstName").contains("Jared"); }).orderBy(function(expressionBuilder){ return expressionBuilder.property("age"); }).take(10); var queryableExpression = queryable.getExpression(); var whereExpression = queryableExpression.where; var orderByExpression = queryableExpression.orderBy; var takeExpression = queryableExpression.take; var sqlVisitor = new SqlVisitor(); var whereString = sqlVisitor.parse(whereExpression); var orderBy = sqlVisitor.parse(orderByExpression); var take = sqlVisitor.parse(takeExpression); console.log(whereString); console.log(orderBy); console.log(take); });