Open GoNode5 opened 11 years ago
I already thought about it. It's also in my plans. Something like:
// look for table 'person' in database and populate properties / associations in model
var Person = db.discover('person');
sounds great !!! Would also be easier to adopt to orm without retyping everything...
I like this, but also would be nice to dump the discovered model to the console or file (for when migrating projects)
+1
This could be done now using plugins. I'm going to try to create a plugin and will post the link here when I have something.
Has there been any progress on this?
A data-intensive application I am working on needs it. If there hasn't been much done, I plan to start tackling this for at least PostgreSQL.
So I have a working piece of code that reverse engineers orm models from a PostgreSQL database. I need to generalize this and write tests for it, but I do have a question. To launch this command, to generate the models, how would we do this.
Make it a script available when you globally install? Make a grunt task? Would anyone be opposed to grunt?
I'm for a grunt task.
On Tue, Feb 25, 2014 at 9:11 AM, Lawrence Selvy notifications@github.comwrote:
So I have a working piece of code that reverse engineers orm models from a PostgreSQL database. I need to generalize this and write tests for it, but I do have a question. To launch this command, to generate the models, how would we do this.
Make it a script available when you globally install? Make a grunt task? Would anyone be opposed to grunt?
Reply to this email directly or view it on GitHubhttps://github.com/dresende/node-orm2/issues/105#issuecomment-36010401 .
mspisars@gmail.com
"I cannot imagine how the clockwork of the universe can exist without a clockmaker." - Voltaire
What does dresende think about this? It would add a dependency to the library.
ORM needs to be independent of grunt, broccoli, cabbage or anything else. It should have a function that can be called by any of the mentioned frameworks. One could also create some sort of executable if need be - which just calls this function.
I'm curious about the code itself; does it in some way integrate with sql-ddl-sync which is now a dependency of ORM ?
Currently the code is implemented as a script.
It currently is not specifically integrated with sql-ddl-sync. The code is entirely dependent on ORM and does raw queries to inspect the PostgreSQL meta catalog.
The issue I am having is that you this runs outside of any framework or use of ORM. IT is its own application basically, looking at the schema within the Postgres and then making model definitions for it. It prints all of these out to stdout so they can later be used in a file inside of a framework.
I understand wanting to keep node-orm2 separate from all of these task runners, in that case the best that can be done is to have a script file somewhere and during global installation install it somewhere to be used. I think that's about all we can do.
Ahh makes sense. Given that it is totally postgres specific & it's own standalone app, I think it would make sense to make it a separate package and we can have a link in the readme. If we put it in ORM core, people will expect it to 'just work' in mysql & sqlite and so that may introduce confusion. What are your thoughts?
sql-ddl-sync
could help this task a lot. I'm not sure if it's feasible but it could be a more clean way of doing it since it already abstracts the several drivers.
@dxg I am working on generalizing the script right now. Basically it just uses the meta-data catalogs (information_schema databases/schema) for the SQL databases and fill in everything that it can from the definitions therein. Hopefully soon I will be able to get this to work with sql-ddl-sync's Dialects and all SQL databases. Unfortunately, for no-sql databases, this sort of inspection does not necessarily make sense, as every entry in a group may be significantly different.
@dresende I am going to try and integrate with sql-ddl-sync
, but the actual script should remain with orm, as it builds orm models.
I do have a general question that this sort of hints at, how do you keep all these sub-packages in line? For instance, I may have to change some in the sql-ddl-sync dialects to get this integrated properly, but that means everything has to be updated for the effects to be felt in orm2. Do you just make sure when updating for npm usage you update all of the simultaneously?
First, you suggest or request the changes on the sql-ddl-sync
. Then we can publish a new version of it and orm can update it's dependencies and publish a version too later on.
Alright, sounds good. I'll work on getting the script working with sql-ddl-sync. On Feb 28, 2014 7:07 PM, "Diogo Resende" notifications@github.com wrote:
First, you suggest or request the changes on the sql-ddl-sync. Then we can publish a new version of it and orm can update it's dependencies and publish a version too later on.
Reply to this email directly or view it on GitHubhttps://github.com/dresende/node-orm2/issues/105#issuecomment-36407846 .
I just want to share this with you guys. https://github.com/sequelize/sequelize-auto
Hello there, four years later and still nothing.. To be honest I first tried Sequelize (yes the concurrent 😆 ) but I have faced a lot of issues with the relations between tables. Then I have switched to orm2 but faced this problem.. However I'm not here to complain, just wanted to know if there is any evolution with this, I don't want to make a whole script that I would throw to trash right after that.. ORM is awesome, but need this (really annoying) feature. Thank you.
thnx for node-orm2.
Would reversere engineer an existing table/database to node-orm2 model an possibilty in the future?