Skip to content
This repository has been archived by the owner on Oct 10, 2022. It is now read-only.

MySQL multiple database attr force option #204

Open
CatsMiaow opened this issue Sep 17, 2019 · 4 comments
Open

MySQL multiple database attr force option #204

CatsMiaow opened this issue Sep 17, 2019 · 4 comments
Labels
enhancement new feature or bug with easy workaround

Comments

@CatsMiaow
Copy link
Contributor

CatsMiaow commented Sep 17, 2019

I'm using multiple database. db1, db2, db3 ...

-d db1 does not add the database attribute.

@Entity("Table", { schema: "db1" })

https://github.com/Kononnable/typeorm-model-generator/blob/master/src/drivers/AbstractDriver.ts#L208

ent.Database = dbNames.includes(",") ? val.DB_NAME : "";

multiple databases require ,

-d db1,db2,db3 This adds the database properties but outputs all the files in one place.
I want to create a folder for each database and specify the folder name when importing entities.

import { Tables } from './entity/db1/tables';

I think it would be nice to have the option of forcibly adding a database attribute even if you enter a single db(-d db1).

@CatsMiaow CatsMiaow changed the title MySQL muitiple database attr force option MySQL multiple database attr force option Sep 17, 2019
@Kononnable
Copy link
Owner

It should be easy to implemented, but I'm not sure about the design(in general). Lately we've been adding more and more options to customize generated models. The list of command parameters is getting longer and longer and I don't really like where this is going(but didn't find a better solution yet).

@Kononnable Kononnable added the enhancement new feature or bug with easy workaround label Sep 17, 2019
@Kononnable
Copy link
Owner

It's a bit hacky way, but actually you can achieve this right now. Just add a coma after db name -d db1,. Alternatively you can specify db which does not exits. This way library will thin that results might be from different databases and will generate database attribute.

@CatsMiaow
Copy link
Contributor Author

I think it would be nice to have a configuration file like ormconfig.json or tsconfig.json if you have a lot of parameters.

typeorm-model-generator --noConfig --ce pascal -h host -p port -d database -u username -x password -e mysql -o entity ...
typeorm-model-generator -c config.path.json

@Kononnable
Copy link
Owner

You can run typeorm-model-generator without passing any parameters. You'll enter wizard mode which will offer to save setting to configuration file.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement new feature or bug with easy workaround
Projects
None yet
Development

No branches or pull requests

2 participants