Mongo selector SQL builder (WIP)
Build an SQL selector (WHERE
) from a Mongo selector.
NOTE: Currently the produced SQL is mysql opinionated
Install
npm install mongoloidsql
Usage
Example 1
var builder = ; console
Output:
SELECT * FROM `table` WHERE `id` = 1
Example 2
var builder = ; console
Output:
SELECT * FROM `table` WHERE `id` = 1 AND `test` > 1
etc...
what what
var builder = ; console; }));
Output:
SELECT * FROM `table` WHERE (`col1` = 1 AND ((`col2` = 2 OR `col3` = 3) AND `col4` = 4 AND `col5` != 5 AND (`col6` > 6 AND `col7` <= 7 AND (`col8` > 6 OR `col9` <= 7))) AND ((`col2` = 2 OR `col3` = 3) OR `col4` = 4 OR `col5` != 5 OR (`col6` > 6 AND `col7` <= 7 AND (`col8` > 6 OR `col9` <= 7))))
Reference
- https://docs.mongodb.org/manual/tutorial/query-documents/
- https://docs.mongodb.org/manual/reference/operator/query/