joli.js icon indicating copy to clipboard operation
joli.js copied to clipboard

Database First

Open whitneyland opened this issue 13 years ago • 1 comments

Salut Xavier –

Have you ever considered a feature that would generate the javascript necessary to define joli models by reading an existing database?

So for example a utility could exists that takes as input a SQLite database file, and generates the model definitions by emitting javascript, which could then be used by joli.

This is sometimes referred to in the ORM world as a “database first” approach.

The advantage of this approach would be there is no need to manually define models for databases which already exist.

I am interested in your opinion on the feasibility of this approach with joli.

Regards, Lee

whitneyland avatar Dec 07 '11 21:12 whitneyland

Hi WhitneyLand,

Sorry for the delay, I've been rather busy on other topics lately. I have pushed yesterday a new version of joli.js, which allows to embed a pre-existing database. It won't retro-engeneer the database (so you still have to write the definition of the models), but it allows to open a database bundled in your app.

As for a utility which would help converting an existing database into the joli.js model definition file, taht would be a great idea, and actually not complicated to achieve - just a matter of introspecting the database and generate a model object for each of the tables. I don't know if you have gone ahead with this idea during the last few months. If it is the case, you 'are welcome to share your code :)

xavierlacot avatar Jun 21 '12 11:06 xavierlacot