synatic / noql Goto Github PK
View Code? Open in Web Editor NEWConverts SQL queries to Mongo find or aggregates
Home Page: https://noql.synatic.dev/
License: GNU General Public License v3.0
Converts SQL queries to Mongo find or aggregates
Home Page: https://noql.synatic.dev/
License: GNU General Public License v3.0
select count(*) as theCount from collection
should add a last pipeline stage
{
$count: "theCount"
}
But need to double check when grouping by different fields
https://docs.mongodb.com/manual/reference/operator/aggregation/count/
select cast(a as Int) as s from collection
SELECT *,convert(id,'int') as idConv FROM customers
Only supported with aggregation, needs to be tested for
Please add support for CURRENT_DATE()
.
I currently get Error: Function:CURRENT_DATE not available
.
My query:
SELECT COUNT(*) as count, MONTH(data.returnDate) as month
FROM package
WHERE YEAR(data.returnDate) = YEAR(CURRENT_DATE())
GROUP BY MONTH(data.returnDate)
It would be cool to see this library work for basic create-update-delete operations. No need to support anything crazy like subqueries, etc.
I'd be willing to take a stab at the PR for it if this isn't an easy feature to implement ๐
Example:
select a.ID as aId,
b.name as bName
from [something.tablea] a
join [something.tableb] b on a.ID = b.ID and b.IsDeleted = 'false'
This query (and ones more complicated, where a conditional in a join makes sense) will fail. This will throw the error in makeFilterCondition.js: invalid expression type for array sub select:bool, as it identifies the conditional in the join as a subselect. Simply adding 'bool' to the array on line 169 in the same file fixes this issue.
select (log10(3) * floor(a) + 1) as s from collection
Is there a way to achieve a NOT LIKE statement? Thanks!
const SQLParser = require('@synatic/noql');
Promise.resolve()
.then(async function () {
const query = `select A.name, B.name, C.name
from \`user-books\` as UB, books as B, users as A, authors as C
where UB.book = B._id AND UB.user = A._id AND B.author = C._id
`;
const parsedSQL = SQLParser.parseSQL(query);
console.log(parsedSQL);
})
.catch(err => console.error(err));
Throws an error
TypeError: Cannot read properties of undefined (reading 'left')
at shouldPrefixSide ($project\node_modules\@synatic\noql\lib\make\makeJoinForPipeline.js:236
:30)
at makeJoinPart ($project\node_modules\@synatic\noql\lib\make\makeJoinForPipeline.js:104:24)
at Object.makeJoinForPipeline ($project\node_modules\@synatic\noql\lib\make\makeJoinForPipel
ine.js:48:9)
at Object.makeAggregatePipeline ($project\node_modules\@synatic\noql\lib\make\makeAggregateP
ipeline.js:234:52)
at makeMongoAggregate ($project\node_modules\@synatic\noql\lib\make\index.js:26:47)
at SQLParser.parseSQL ($project\node_modules\@synatic\noql\lib\SQLParser.js:69:16)
at $project\index.js:11:30
select * from (select id,First Name
,Last Name
,arrayLength(Rentals
,'id') as rentalCount from customers) as t
node_modules/@synatic/noql/node_modules/bson/lib/bson.mjs:142:28:
Unexpected reserved word 'await'. (142:28)
This error appears in my meteor app that uses node version 14.21.3
select id,First Name
,Last Name
,sumArray(Rentals
,saleId
) as totalIdRentals from customers
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.