mirror of
https://github.com/nocobase/nocobase
synced 2024-11-16 05:35:17 +00:00
20 lines
522 B
TypeScript
20 lines
522 B
TypeScript
import path from 'path';
|
|
import { Application } from '@nocobase/server';
|
|
import { registerModels, Table } from '@nocobase/database';
|
|
import * as models from './models';
|
|
|
|
export default async function (this: Application, options = {}) {
|
|
const database = this.database;
|
|
registerModels(models);
|
|
|
|
database.import({
|
|
directory: path.resolve(__dirname, 'collections'),
|
|
});
|
|
|
|
database.getModel('fields').beforeCreate((model) => {
|
|
if (!model.get('name')) {
|
|
model.set('name', model.get('key'));
|
|
}
|
|
});
|
|
}
|