You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fist of all, thank you for creating this repo! This is definitely more useful that the stale sequelize-auto repo out there.
Unfortunately, it does not fully fit my bill. To give you some background: my project has about 300 MySql tables, with tables relating to each other in many-to-one and many-to-many relationships and the code is purely in typescript using sequelize version 6 (!). Using your very nicely written (:clap:) module gets me maybe 80% to were I would like to be, but unfortunately it lacks some flexibility. Here a short list:
sequelize 6 is not supported. For example, DataTypes.INTEGER(10) is DataTypes.INTEGER({ length: 10}) in V6
since I have so many tables, I would need the associations being generated as well.
.d.ts files are actually required for JS modules that can be consumed by typescript code. If the code is already in TS, the interface definitions would go directly into the .ts files
the models are lacking the generic type. sequelize.define(..) returns a model with its internal type being any. A slightly better solution would be to pass in the generics that are generated in the .d.ts files, so sequelize.define<MyModelAttributes,>(..), BUT ...
sequelize.define() is one of the two ways you can define a model, but since I want to add custom functions to my models, I actually want to have a class on which I would call init:
// I have timestamps on most of my tables, so I have an interface for the timestamp fieldsexportinterfaceUserAttributesextendsCreateableModel,ModifiableModel{userId: numbername: string}// Your code is aware of optional fields, since it puts a "?" on those in the interface// It would be nice if it would create this second interface for sequelizeexportinterfaceUserCreationAttributesextendsOptional<UserAttributes,'userId'>{}// this is how I need the initialisation to work: create a class and call init() on it:classUserextendsModel<UserAttributes,UserCreationAttributes>implementsUserAttributes{publicuserId!: numberpublicname!: stringpubliccreated!: Datepublicmodified!: DatepublicstaticfunctionmyCustomStaticFunc(){}publicfunctionmyCustomInstanceFunc(){}}// small improvement: sequelize provides a wrapper to create an interface for the static parts of the model.// Important though, it needs to be exported, since this is what I need everywhere in the codeexporttypeUserModel=ModelCtor<User>// the initialiser that is called on app startup exportdefault(sequelize: Sequelize)=>{constattributes={...}constoptions={...}// unfortunately, your script does not give my any control over these options like the `timestamp` for exampleUser.init(attributes,options)}
Long story short, I would need some tweaks that are currently not supported. But instead of adding support for a lot of flags and switches to the sequelize-automate.config.json, I instead propose the following:
Why not use a templating engine like handlebars or EJS internally and allow the user to provide their own templates!
I believe this would give users the biggest flexibility, would be future-proof for new sequelize versions and any other changes, since it would just involve creating a new template to use.
What do you think ?! (sorry for my length explanations, I hope I did not waste your time)
The text was updated successfully, but these errors were encountered:
Hi!
Fist of all, thank you for creating this repo! This is definitely more useful that the stale
sequelize-auto
repo out there.Unfortunately, it does not fully fit my bill. To give you some background: my project has about 300 MySql tables, with tables relating to each other in many-to-one and many-to-many relationships and the code is purely in typescript using sequelize version 6 (!). Using your very nicely written (:clap:) module gets me maybe 80% to were I would like to be, but unfortunately it lacks some flexibility. Here a short list:
DataTypes.INTEGER(10)
isDataTypes.INTEGER({ length: 10})
in V6.d.ts
files are actually required for JS modules that can be consumed by typescript code. If the code is already in TS, the interface definitions would go directly into the.ts
filessequelize.define(..)
returns a model with its internal type beingany
. A slightly better solution would be to pass in the generics that are generated in the.d.ts
files, sosequelize.define<MyModelAttributes,>(..)
, BUT ...sequelize.define()
is one of the two ways you can define a model, but since I want to add custom functions to my models, I actually want to have a class on which I would callinit
:Long story short, I would need some tweaks that are currently not supported. But instead of adding support for a lot of flags and switches to the
sequelize-automate.config.json
, I instead propose the following:Why not use a templating engine like handlebars or EJS internally and allow the user to provide their own templates!
I believe this would give users the biggest flexibility, would be future-proof for new sequelize versions and any other changes, since it would just involve creating a new template to use.
What do you think ?! (sorry for my length explanations, I hope I did not waste your time)
The text was updated successfully, but these errors were encountered: