Coder Social home page Coder Social logo

Comments (19)

ujwal-setlur avatar ujwal-setlur commented on August 17, 2024 1

I can take a stab at this.

from ucast.

stalniy avatar stalniy commented on August 17, 2024

Awesome! Let me know if you have any questions!

from ucast.

stalniy avatar stalniy commented on August 17, 2024

Hi @ujwal-setlur

Do you have any news on the progress?

from ucast.

ujwal-setlur avatar ujwal-setlur commented on August 17, 2024

from ucast.

stalniy avatar stalniy commented on August 17, 2024

@ujwal-setlur , do you have free time for this task now?

from ucast.

stalniy avatar stalniy commented on August 17, 2024

Interpreter for Objectionjs was finished and it may be a very good reference implementation for mikro orm

from ucast.

Asoftyn avatar Asoftyn commented on August 17, 2024

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.

stalniy avatar stalniy commented on August 17, 2024

Hi @Asoftyn

No any progress on this. Your help would be very useful!

from ucast.

stalniy avatar stalniy commented on August 17, 2024

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.

ujwal-setlur avatar ujwal-setlur commented on August 17, 2024

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.

stalniy avatar stalniy commented on August 17, 2024

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.

Asoftyn avatar Asoftyn commented on August 17, 2024

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.

stalniy avatar stalniy commented on August 17, 2024

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.

Asoftyn avatar Asoftyn commented on August 17, 2024

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.

stalniy avatar stalniy commented on August 17, 2024

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.

Asoftyn avatar Asoftyn commented on August 17, 2024

Im not sure i understand the "as won't fix" part but good luck.

from ucast.

ujwal-setlur avatar ujwal-setlur commented on August 17, 2024

I guess it means it’s generic enough to cover all the SQL ORMs?

from ucast.

stalniy avatar stalniy commented on August 17, 2024

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.

stalniy avatar stalniy commented on August 17, 2024

close in favor of #8

from ucast.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.