2021-02-22 15:08:35 +08:00
|
|
|
import path from 'path';
|
2021-09-11 18:53:26 +08:00
|
|
|
import Database, { registerModels } from '@nocobase/database';
|
2021-04-01 09:58:30 +08:00
|
|
|
import { ChinaRegion } from './models/china-region';
|
2021-09-11 18:53:26 +08:00
|
|
|
import Application from '@nocobase/server';
|
2021-02-22 15:08:35 +08:00
|
|
|
|
2021-09-11 18:53:26 +08:00
|
|
|
registerModels({ ChinaRegion });
|
|
|
|
|
|
|
|
export default async function (this: Application, options = {}) {
|
2021-09-14 11:09:26 +08:00
|
|
|
const { db } = this;
|
2021-09-11 18:53:26 +08:00
|
|
|
|
2021-09-14 11:09:26 +08:00
|
|
|
db.import({
|
2021-02-22 15:08:35 +08:00
|
|
|
directory: path.resolve(__dirname, 'collections'),
|
|
|
|
});
|
2021-09-11 18:53:26 +08:00
|
|
|
|
2021-09-14 11:09:26 +08:00
|
|
|
this.on('db.init', async () => {
|
|
|
|
const M = db.getModel('china_regions');
|
2021-09-11 18:53:26 +08:00
|
|
|
await M.importData();
|
|
|
|
});
|
2021-02-22 15:08:35 +08:00
|
|
|
}
|