samuelneff / sequelize-auto-ts

Generate Sequelize definition statements and compatible TypeScript definitions from a database schema
MIT License
79 stars 20 forks source link

Question: Why not generate interfaces based on sequelize definitions? #9

Closed paulkoerbitz closed 8 years ago

paulkoerbitz commented 8 years ago

First of all many thanks for the development of sequelize-auto-ts - I would love to use it ;) The reason that I can't use it right now is that we use postrgres as our database, so I think we would need to write a new schema dialect layer.

I was wondering why one wouldn't base the generation of interfaces directly - after all that's what most (all?) users of sequelize already have and it is what sequelize is drawing all its information from? Could this be a way to avoid having special code for every db or is this a bad idea?

samuelneff commented 8 years ago

The reason I pull from the database is precisely because I do not have the sequelize definitions. sequelize-auto-ts provides to features.. it creates interfaces for all your table definitions, and it creates sequelize model definitions. sequelize itself is based around model first which admittedly is the direction most ORMs have gone. I'm more traditional and prefer to work on my schema in my database, not in my model, and thus I created a tool to support database first with sequelize.

There were other people interested in Postgres too and I think one of them started working on a patch but never got it done or submitted. I'm too busy now to do it myself, since I don't have a personal need, but if someone comes up with one that works transparently I'll be happy to merge it.

Thanks,

Sam

paulkoerbitz commented 8 years ago

Hi Sam,

thank you for explaining the reasons. I understand better now and know the time constraints you speak about all too well. I'll have a look at generating interfaces from sequelize definitions (not making any promises here...).

Thank you Paul

samuelneff commented 8 years ago

Sure, shouldn't be all that difficult, but that's usually the last word of any software developer before jumping down some bottomless rabbit hole, right?

Anyways, sequelize-auto-ts defines an object model for storing the schema definition and builds this up from the schema defined in the database. If you build the same object model from existing sequelize definitions, then you can use the rest of sequelize-auto-ts as is.

HTH,

Sam

paulkoerbitz commented 8 years ago

Yeah, famous last words ;) OK, it does sound manageable indeed, the one problem is that I don't know how sequelize represents its definitions, so I guess I have to figure that out ;)

Anyway, thanks for your input - if I manage to get this going I'll let you know.

On Sat, Apr 9, 2016 at 3:23 PM, Samuel Neff notifications@github.com wrote:

Sure, shouldn't be all that difficult, but that's usually the last word of any software developer before jumping down some bottomless rabbit hole, right?

Anyways, sequelize-auto-ts defines an object model for storing the schema definition and builds this up from the schema defined in the database. If you build the same object model from existing sequelize definitions, then you can use the rest of sequelize-auto-ts as is.

HTH,

Sam

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/samuelneff/sequelize-auto-ts/issues/9#issuecomment-207788737