diff --git a/packages/plugin-collections/src/hooks/collections-after-create.ts b/packages/plugin-collections/src/hooks/collections-after-create.ts index ebc468b23..7b39471a0 100644 --- a/packages/plugin-collections/src/hooks/collections-after-create.ts +++ b/packages/plugin-collections/src/hooks/collections-after-create.ts @@ -73,6 +73,18 @@ const defaultValues = { default: true, }, ], + scopes: [ + { + title: '全部数据', + filter: {}, + }, + { + title: '用户自己的数据', + filter: { + "created_by_id.$currentUser": true, + }, + }, + ], }; export default async function (model: CollectionModel, options: any = {}) { diff --git a/packages/plugin-permissions/src/server.ts b/packages/plugin-permissions/src/server.ts index 84876d908..2cdfcc2ea 100644 --- a/packages/plugin-permissions/src/server.ts +++ b/packages/plugin-permissions/src/server.ts @@ -55,12 +55,12 @@ export class Permissions { // const s = await model.createScope(scope, options); // console.log(s.toJSON()); // } - try { - await Scope.bulkCreate(defaultScopes.map(scope => ({...scope, collection_name: model.get('name')}))); - } catch (error) { - console.error(error); - throw error; - } + // try { + // await Scope.bulkCreate(defaultScopes.map(scope => ({...scope, collection_name: model.get('name')}))); + // } catch (error) { + // console.error(error); + // throw error; + // } }); database.getModel('users').addHook('afterCreate', async(model, options) => {