tachybase_todo/packages/plugin-users/src/hooks/fields-before-create.ts
Junyi 110d5bcc9c
feat: add createdBy/updatedBy field config for table managed by collections (#43)
* feat: add createdBy/updatedBy field config for table managed by collections

* fix: update by different users and field initialization

* fix: function argument

* add: test cases

Co-authored-by: chenos <chenlinxh@gmail.com>
2020-12-18 09:04:40 +08:00

19 lines
595 B
TypeScript

import { Model, getDataTypeKey, getField } from '@nocobase/database';
export default async function(model: Model, options) {
// const { database } = model;
// const { type, target, collection_name } = model.get();
// const table = database.getTable(collection_name);
// const Type = getField(getDataTypeKey(type));
// let Exist;
// for (const Field of table.getFields().values()) {
// if (Field instanceof Type && Field.options.target === target) {
// Exist = Field;
// break;
// }
// }
// if (Exist) {
// model.set('name', Exist.options.name);
// }
}