tachybase_todo/packages/plugin-china-region/src/server.ts

20 lines
499 B
TypeScript
Raw Normal View History

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-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({
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();
});
}