Open hotaru355 opened 3 years ago
Hi @hotaru355 , thanks for your feedback, they are very valuable.
associations
is a bit diffcult, so it's not support now.any
type, there are something wrong with sequelize 5 types, see also https://github.com/nodejh/sequelize-automate/issues/11 , I will check in sequelize 6.I will fix these issues, but may take a while.
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
:// 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 sequelize export interface UserCreationAttributes extends Optional<UserAttributes, 'userId'> {}
// this is how I need the initialisation to work: create a class and call init() on it: class User extends Model<UserAttributes, UserCreationAttributes> implements UserAttributes { public userId!: number public name!: string public created!: Date public modified!: Date
public static function myCustomStaticFunc() {} public function myCustomInstanceFunc() {} }
// 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 code export type UserModel = ModelCtor
// the initialiser that is called on app startup export default (sequelize: Sequelize) => { const attributes = {...} const options = {...} // unfortunately, your script does not give my any control over these options like the
timestamp
for example User.init(attributes, options) }