Skip to content

Commit

Permalink
尝试写extension
Browse files Browse the repository at this point in the history
  • Loading branch information
skydtrtzmr committed Dec 7, 2024
1 parent 92246d5 commit 8519fad
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 57 deletions.
25 changes: 25 additions & 0 deletions api/extensions/directus-extension-create-user/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

export default ({ filter }, context) => {
const { services, getSchema } = context; // getSchema is a function that returns the schema of the current collection
const { ItemsService, UsersService, RolesService, PermissionsService } = services; // get the services we need

const functionName = async (input, meta, context) => {
console.log('Creating Student Item!');

input.number = 1706;

// const schema = await getSchema(); // 会报错
// const { accountability } = context;
// const itemsService = new ItemsService('students', { schema });

// const data = await itemsService.createOne({
// number: 22,
// email: 'hello@world.com',
// name: 'This is our first article',
// });

return input;
};

filter('students.items.create', functionName);
};

This file was deleted.

65 changes: 65 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8519fad

Please sign in to comment.