tachybase_todo/packages/plugin-collections/src/hooks/fields-after-create.ts
chenos ecab106c3c
feat: support subTable field
* feat: add linkTo and subTable fields

* add subTable field component

* improve sub table

* bugfix
2020-12-20 12:52:15 +08:00

16 lines
496 B
TypeScript

import FieldModel from '../models/field';
export default async function (model: FieldModel, options: any = {}) {
const { migrate = true } = options;
if (migrate) {
await model.migrate(options);
}
if (model.get('collection_name') && model.get('parent_id')) {
const parent = await model.getParent({
...options,
});
const Collection = model.database.getModel('collections');
await Collection.load({...options, where: {name: parent.get('collection_name')}});
}
}