Comments (19)
I can take a stab at this.
from ucast.
Awesome! Let me know if you have any questions!
from ucast.
Do you have any news on the progress?
from ucast.
from ucast.
@ujwal-setlur , do you have free time for this task now?
from ucast.
Interpreter for Objectionjs was finished and it may be a very good reference implementation for mikro orm
from ucast.
Hi, I wonder if there is any progress on this?
And if I would try to do this, where would I start so I could get a better understanding of ucast? Since I am a little confused about what it does right now.
from ucast.
Hi @Asoftyn
No any progress on this. Your help would be very useful!
from ucast.
The best way to start is to read this https://github.com/stalniy/ucast/tree/master/packages/core
UCAST is a universal conditions translator. It allows to translate conditions from one language to another. More formally, there are 3 things:
- Parser. parses language which we want to translate into intermediate language (i.e., object structure called AST)
- Intermediate language (AST). Recursive composition of objects that represent conditions
- Interpreter. Function that interprets intermediate language (AST) in some way.
What does this allow?
@ucast/mongo
contains a parser that translates MongoDB into AST. Now, we need an interpreter that can convert this AST into mikro-orm query builder
from ucast.
Sorry folks, I got extremely busy on my day job. Any help would be appreciated. I hope to get a break at work in a couple of weeks
from ucast.
This may sound confusing and complicated but in fact, interpreter is a simple set of functions. Take a look at @ucast/objection
implementation (https://github.com/stalniy/ucast/blob/master/packages/objection/src/interpreters.ts#L11) which is similar thing for Objection.js ORM.
Let me know if you have further questions
from ucast.
I had a look around and from what I understand is that mikro-orm has support for mysql, postgresql, sqlite and mongo and is using knex.
So I was thinking that an mongodb interpreter already exists and so does one for the others using objection.js with knex. So wouldn't the interpreter part already be kinda done? Could we Frankenstein something together using code from those interpreters for the mikro-orm interpreter?
Sorry if I sound stupid I'm not used to these kinda things.
from ucast.
I thought about similar possibilities, this requires implementation of Adapter pattern that will unify interfaces of different query builders. As a result this adds additional level of abstraction, basically another query builder interface. The issue is that for some edge cases this abstraction won't work well:
- to generate raw queries. Different ORMs may use even different binding parameters.
- to wrap SQL expressions in brackets. Some supports nested query builder and others - not. So, this will make implementation of Adapter pattern for some ORMs more complicated than it should be. For example, sequelize uses objects to construct query. So, for example to implement
and
operator, we will need to create an instance of nested query builder, instead of merging conditions using regular Array.
Being able to implement operators for particular ORM may allow to simplify and optimize implementation for particular situation.
I'd like to start with this approach at least for now, and find out/refactor as we go
from ucast.
I have been trying and looking around at the code for a few hours but i cant get my head around it. So I sadly wont be of any use since i do not quite understand it.
I wish you all good luck with this.
from ucast.
Guys, actually yesterday I tried to implement interpreter for pure SQL. and have pretty good results. Tested it with objectionjs and it works really good.
today, I plan to try it with mikro orm and sequelize and if it works good I’ll publish it and close this issue as won’t fix
from ucast.
Im not sure i understand the "as won't fix" part but good luck.
from ucast.
I guess it means it’s generic enough to cover all the SQL ORMs?
from ucast.
right, I believe that all ORMs in one or another way allow to combine raw sql with their query builder interface, this allows to implement conversion to SQL and use this SQL to set conditions.
from ucast.
close in favor of #8
from ucast.
Related Issues (20)
- interpret from @ucast/sql/objection does not take knexSnakeCaseMappers into account HOT 2
- Feature Request: Prisma interpreter HOT 2
- table name "xxx" specified more than once - objection HOT 8
- sql/objection where clause does not work with relations: 'column reference "id" is ambiguous' HOT 8
- Mongo $and/$or/$nor array items should be validated as objects
- Typeorm interpreter builds conditions with wrong placeholders
- Typeorm interpreter builds a wrong query with "empty" condition HOT 1
- Use LEFT JOIN instead of INNER JOIN when translate condition to SQL
- Columns reference can be ambigous HOT 3
- Builds fails for apps using webpack 5 HOT 4
- interpreter from JSON? HOT 2
- Support conditions that use nested relations HOT 3
- [mongo2js] - Nested object match HOT 2
- Question on how to go about using casl + mikro-orm together HOT 1
- MongoQueryParser Or is Parsed as And HOT 1
- [@ucast/sql] error while install due to wrong typeorm version
- usage question HOT 1
- Not accect array values for TypeOrm qb HOT 7
- Nested compound conditions are not translated correct HOT 4
- `$not` with `$size` does not work HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ucast.