fix: model is not null
This commit is contained in:
parent
aef6b85736
commit
59db7a34dc
@ -239,7 +239,10 @@ export default class Database {
|
|||||||
}
|
}
|
||||||
for (const name of names) {
|
for (const name of names) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
sequelize.modelManager.addModel(this.getModel(name));
|
const model = this.getModel(name);
|
||||||
|
if (model) {
|
||||||
|
sequelize.modelManager.addModel(model);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await sequelize.sync(restOptions);
|
await sequelize.sync(restOptions);
|
||||||
await sequelize.close();
|
await sequelize.close();
|
||||||
|
@ -238,12 +238,13 @@ export class Table {
|
|||||||
*/
|
*/
|
||||||
public getRelatedTableNames(): Set<string> {
|
public getRelatedTableNames(): Set<string> {
|
||||||
const names = new Set<string>();
|
const names = new Set<string>();
|
||||||
names.add(this.options.name);
|
this.options.name && names.add(this.options.name);
|
||||||
for (const association of this.associations.values()) {
|
for (const association of this.associations.values()) {
|
||||||
const target = association.getTarget();
|
const target = association.getTarget();
|
||||||
names.add(target);
|
target && names.add(target);
|
||||||
if (association instanceof BELONGSTOMANY) {
|
if (association instanceof BELONGSTOMANY) {
|
||||||
names.add(association.getThroughName());
|
const throughName = association.getThroughName();
|
||||||
|
throughName && names.add(throughName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return names;
|
return names;
|
||||||
|
Loading…
Reference in New Issue
Block a user