Open donecarlo opened 4 years ago
You could use the --output
and --schema
flags together, to put the models for each schema in their own directory.
You could use the
--output
and--schema
flags together, to put the models for each schema in their own directory.
How does output
differ from the directory
option? Would that also change the model names within sequelize?
My concern is with the model names being registered/defined with Sequelize -- where I intend for all models in Sequelize to be something like: sequelize.schema_TABLE_NAME
, instead of the default sequelize.TABLE_NAME
Oh right, the concern is with the model names, not the file names. Sorry!
Maybe we could change the SequelizeAuto
API to allow you to pass a function to convert the model names.
We couldn't do that from the command line, but we could give a --prefixModelNameWithSchemaName
option.
Oh right, the concern is with the model names, not the file names. Sorry!
Maybe we could change the
SequelizeAuto
API to allow you to pass a function to convert the model names.We couldn't do that from the command line, but we could give a
--prefixModelNameWithSchemaName
option.
Yes, that would be really helpful 😀
Maybe we could change the
SequelizeAuto
API to allow you to pass a function to convert the model names.
This would be nice.
It would also allow us to bypass conversion from plural form for some tables ("singularize": true
) if we disagree with some of the conversion results or want to introduce sequelize-auto to an existing code base and preserve Model names that were previously used
@steveschmitt Is this coming I would love to translate my DB from Czech to English names. I would love to use pluralization too.
My take on API:
interface SingularAndPlural {
readonly singular: string;
readonly plural: string;
}
/** method from `inflection.inflect` - */
type inflectionInflect = (
/** String to transform (provide english string, other may result in wrong results) */
enText: string,
/** 1 for singular, 2 for plural */
number: 1 | 2,
/** Override for singular */
singular: string,
/** Override for plural */
plural: string,
) => string;
interface AutoOptions {
// current options...
renameFile(
originalModelName: string,
singularAndPluratTransform: inflectionInflect,
): string;
renameModel(
originalModelName: string,
singularAndPluratTransform: inflectionInflect,
): SingularAndPlural;
renameProperty(
originalModelName: string,
originalPropertyName: string,
singularAndPluratTransform: inflectionInflect,
): SingularAndPlural;
}
PS: Make this work with TypeScript generator too 😇
Oh right, the concern is with the model names, not the file names. Sorry! Maybe we could change the
SequelizeAuto
API to allow you to pass a function to convert the model names. We couldn't do that from the command line, but we could give a--prefixModelNameWithSchemaName
option.
Honestly, even a static --suffixModelNameWith="MySuffix" would be very helpful for (su | pre)ffixing the names. Is that already a thing?
In my current setup, there are tables with same names under different schemas. As a workaround, I temporarily prefixed the schema name to the model name (which in this case defaults to the table name):
Would it be possible to provide an api that will allow the user to customize the model name, or provide a prefix / suffix to the default model name.
Thanks