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

20 lines
527 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-04-01 09:58:30 +08:00
const { database } = this;
2021-09-11 18:53:26 +08:00
database.import({
directory: path.resolve(__dirname, 'collections'),
});
2021-09-11 18:53:26 +08:00
this.on('china-region.init', async () => {
const M = database.getModel('china_regions');
await M.importData();
});
}