Package to convert json to sql queries.(thought experiment)
Supports
- Selections of columns
- Aliasing of columns
- Support for simple and complex WHERE clause.
- Aggregations of columns with GROUP BY clause.
- Support of ordering ascending and descinding.
- Subquery support.
A object which contains queries defined by name. Eg:
"queries":{
"myTable":{
//...more query details
}
}
A single value text field used to describe the table or subquery it was built on.($
as the first character refers to alies of query in the same file.)
Object containing columns and aliases to be used, it can also contain aggregate functions used by groupby cluase.
- Empty columns array means it will fetch all columns like
*
. alias
array is indexed withcolumns
array directly.$sum
,$count
: Aggregation are currently supported functions.
Allows to define a join statement in the query.
object.key
has to be name of the table to join with.alias
used to define alias.type
type of join Eg: inner, left outer.precedence
order in which operators have to logically combined currently support$and
,$or
.operator
supports different operators like>,<,=,!=,Like,In
.value
operand against which operator has to be executed, support array, single value;$
as first character states as column name.
Allows to define a where clause for the query.
precedence
order in which operators have to logically combined currently support$and
,$or
.operator
supports different operators like>,<,=,!=,Like,In
.value
operand against which operator has to be executed, support array, single value;$
as first character states as column name.
Allows to define a group by clause for the query. Supports array of column names to group by on.
Supports $asc
& $desc
oders for the given columns.
- Git clone the project.
- Copy full path of input and output files to generate in following command.
- Run `node index.js input.json output.sql
- Samples folder containing input and output Samples.
- No NPM packages pure JS code.
- Implemented on visitor pattern can be optimized further using ast.