It is a programmatic tool that helps you write SELECT queries on top of MongoDB collections.
npm install
npm run sql-mongo
3. Formulating the query API Docs
npm run query
import { Parser } from "./models/Parser";
const parser = new Parser(url)
Parameter | Type | Description |
---|---|---|
url |
string |
Required. Connection URL of MongoDB database |
NOTE: The connection url must contain database name
mongodb+srv://url/sample_database
await parser.connect();
parser.query(statement, callback);
Parameter | Type | Description |
---|---|---|
statement |
string |
Required. SQL select statement |
callback |
function |
Required. Callback function to get the results |
SELECT [ * | column name(s) ]
FROM [ collection name ]
[WHERE condition]
At least one of them is required
Parameter | Description |
---|---|
* |
Select all columns |
column1, column2... |
Select one or more specific columns |
At least one collection name is required
Parameter | Description |
---|---|
users |
Name of the collection to perform query |
Conditions with logical and range operators to satisfy for selecting documents
column1=SQL and column2>=n100 or column3 < N200
NOTE: Prefix numbers with n or N. Else they will be parsed as strings
Use the dot annotation to query subdocuments
WHERE customer.name = Tom and customer.age > N28
Supported logical and range operators
Parameter | Type |
---|---|
AND |
Logical |
OR |
Logical |
< |
Range |
> |
Range |
= |
Range |
<= |
Range |
>= |
Range |