apploader处理初始的空数据

This commit is contained in:
Xu Chang 2023-01-12 20:06:32 +08:00
parent 14da761fb3
commit 0e8c27cd03
2 changed files with 20 additions and 16 deletions

View File

@ -120,14 +120,16 @@ class AppLoader extends types_1.AppLoader {
// 对area暂时处理一下
rows = require('./data/area.json');
}
await this.dbStore.operate(entity, {
data: rows,
action: 'create',
}, context, {
dontCollect: true,
dontCreateOper: true,
});
console.log(`data in ${entity} initialized!`);
if (rows.length > 0) {
await this.dbStore.operate(entity, {
data: rows,
action: 'create',
}, context, {
dontCollect: true,
dontCreateOper: true,
});
console.log(`data in ${entity} initialized!`);
}
}
await context.commit();
this.dbStore.disconnect();

View File

@ -152,14 +152,16 @@ export class AppLoader<ED extends EntityDict & BaseEntityDict, Cxt extends Async
// 对area暂时处理一下
rows = require('./data/area.json');
}
await this.dbStore.operate(entity as keyof ED, {
data: rows,
action: 'create',
} as any, context, {
dontCollect: true,
dontCreateOper: true,
});
console.log(`data in ${entity} initialized!`);
if (rows.length > 0) {
await this.dbStore.operate(entity as keyof ED, {
data: rows,
action: 'create',
} as any, context, {
dontCollect: true,
dontCreateOper: true,
});
console.log(`data in ${entity} initialized!`);
}
}
await context.commit();
this.dbStore.disconnect();