-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discussion: abstract syntax tree #202
Comments
Would exposing the operator factory solve your problem? For example: import {createQueryOperation} from "sift";
const operation = createQueryOperation({ age: { $gt: 1 }});
Operators are basically ASTs - I may need to do some work to expose their raw query values, but that shouldn't be hard. From there, you can just roll your own translator: import {createQueryOperation} from "sift";
const operation = createQueryOperation({ age: { $gt: 1, $lt: 10 }});
const searchQuery = mongodbQueryToSqlSearch(operation); // age > 1 AND age < 10 |
Looks fine, but to make sure that we are on the same page, the end result I expect should be this: import { createQueryOperation, test } from "sift";
const operation = createQueryOperation({ age: { $gt: 1, $lt: 10 }});
const searchQuery = mongodbQueryToSqlSearch(operation); // age > 1 AND age < 10
const matches = test(operation, { age: 2 }) // true Update: the last line is equivalent to |
Hi Craig,
Currently, I’m working on SQL integration in CASL and I need to transform Mongo query into sql query. The standard way to do something like this is through AST. There are 2 steps:
So, having AST of Mongo query in casl, I’ll be able to use the same pattern for 2 cases:
To do this I need to implement just 2 separate implementations: RuntimeQueryIterator and SQLIterator
So, what do you thing?
Theoretically it should help with Async operators support as well. Your current design is quite similar to what I need the difference is that your objects currently encapsulate data (about operator) and behavior (how to apply this operator).
I know that you refactored the whole package recently and understand that you may have own vision on siftjs future. So, feel free to decline and close this discussion.
The text was updated successfully, but these errors were encountered: