useDirectusUsers
If you are looking to get data for the current login user, check out the Directus useDirectusUser documentation.
getUsers
Search for users, global search querys
can be used
Arguments: (optional)
- id: string;
- params:
global search querys
, with support for metadata
Returns:
Array of DirectusUser
- In case Metadata are requested by
global search querys
:{"data":[...] "meta":{...}}
JavaScript
<script setup>const { getUsers } = useDirectusUsers();const users = await getUsers();</script>
getUserById
Search for a user by id
Arguments:
- data:
DirectusUserRequest
Returns:
DirectusUser
- In case Metadata are requested by
global search querys
:{"data":[...] "meta":{...}}
JavaScript
<script setup>const { getUserById } = useDirectusUsers();const user = await getUserById({ id: "1",});</script>
createUsers
Create one or multiple users
Arguments:
- data: array or single
DirectusUser
Returns: Array<T>
JavaScript
<script setup>const { createUsers } = useDirectusUsers();const user = await createUsers({ // ... user object or array of user});</script>
deleteUsers
Delete one or multiple users
- Arguments:
- data:
multiple (array)
{ users: [ '4776864a-75ee-4746-9ef4-bd5c2e38cc66', '4776864a-75ee-4746-9ef4-bd5c2e38cc67', '4776864a-75ee-4746-9ef4-bd5c2e38cc68' ];}
- Returns:
Empty body
JavaScript
<script setup>const { deleteUsers } = useDirectusUsers();const user = await deleteUsers({ users: ["4776864a-75ee-4746-9ef4-bd5c2e38cc66"],});</script>
updateUser
Update user
Arguments:
- ID
- user:
DirectusUser
Returns: Array<T>
JavaScript
<script setup>const { updateUser } = useDirectusUsers();const user = await updateUser({ id: "1", user:{ // DirectusUser first_name: 'Abraham', last_name: 'Lincoln', location: 'Hodgenville, KY'}});</script>
Table of Contents