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暂时处理一下 // 对area暂时处理一下
rows = require('./data/area.json'); rows = require('./data/area.json');
} }
await this.dbStore.operate(entity, { if (rows.length > 0) {
data: rows, await this.dbStore.operate(entity, {
action: 'create', data: rows,
}, context, { action: 'create',
dontCollect: true, }, context, {
dontCreateOper: true, dontCollect: true,
}); dontCreateOper: true,
console.log(`data in ${entity} initialized!`); });
console.log(`data in ${entity} initialized!`);
}
} }
await context.commit(); await context.commit();
this.dbStore.disconnect(); this.dbStore.disconnect();

View File

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