Skip to main content
Skip to main content
You're viewing the documentation for v1, which isn't the latest Medusa version.Latest documentation

IUserModuleService

The main service interface for the user module.

Methods

validateInviteToken

This method validates an invite token.

Parameters

tokenstringRequired
The token to validate.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<InviteDTO>Required
The associated invite's details.

refreshInviteTokens

Parameters

inviteIdsstring[]Required
sharedContextContext

Returns

PromisePromise<InviteDTO[]>Required

retrieve

This method retrieves a user by its ID.

Example

A simple example that retrieves a {type name} by its ID:

{example-code}

To specify relations that should be retrieved:

{example-code}

Parameters

idstringRequired
The ID of the retrieve.
The configurations determining how the user is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a user.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<UserDTO>Required
The retrieved user.

list

This method retrieves a paginated list of users based on optional filters and configuration.

Example

To retrieve a list of {type name} using their IDs:

{example-code}

To specify relations that should be retrieved within the {type name}:

{example-code}

By default, only the first {default limit} records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:

{example-code}

Parameters

The filters to apply on the retrieved user.
The configurations determining how the user is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a user.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<UserDTO[]>Required
The list of users.

listAndCount

This method retrieves a paginated list of user along with the total count of available users satisfying the provided filters.

Example

To retrieve a list of {type name} using their IDs:

{example-code}

To specify relations that should be retrieved within the {type name}:

{example-code}

By default, only the first {default limit} records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:

{example-code}

Parameters

The filters to apply on the retrieved user.
The configurations determining how the user is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a user.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<[UserDTO[], number]>Required
The list of users along with their total count.

create

**create**(data, sharedContext?): Promise&#60;[UserDTO](types.UserTypes.UserDTO.mdx)[]&#62;

This method creates users.

Example

{example-code}

Parameters

dataCreateUserDTO[]Required
The users to be created.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<UserDTO[]>Required
The created users.

**create**(data, sharedContext?): Promise&#60;[UserDTO](types.UserTypes.UserDTO.mdx)&#62;

This method creates a user.

Example

{example-code}

Parameters

dataCreateUserDTORequired
The user to be created.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<UserDTO>Required
The created user.

update

**update**(data, sharedContext?): Promise&#60;[UserDTO](types.UserTypes.UserDTO.mdx)[]&#62;

This method updates existing users.

Example

{example-code}

Parameters

dataUpdateUserDTO[]Required
The attributes to update in each user.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<UserDTO[]>Required
The updated users.

**update**(data, sharedContext?): Promise&#60;[UserDTO](types.UserTypes.UserDTO.mdx)&#62;

This method updates an existing user.

Example

{example-code}

Parameters

dataUpdateUserDTORequired
The attributes to update in the user.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<UserDTO>Required
The updated user.

delete

This method deletes users by their IDs.

Example

{example-code}

Parameters

idsstring[]Required
The list of IDs of users to delete.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<void>Required
Resolves when the users are deleted.

softDelete

Type Parameters

TReturnableLinkableKeysstringRequired

Parameters

userIdsstring[]Required
configSoftDeleteReturn<TReturnableLinkableKeys>
sharedContextContext

Returns

PromisePromise<void | Record<TReturnableLinkableKeys, string[]>>Required

restore

Type Parameters

TReturnableLinkableKeysstringRequired

Parameters

userIdsstring[]Required
configRestoreReturn<TReturnableLinkableKeys>
sharedContextContext

Returns

PromisePromise<void | Record<TReturnableLinkableKeys, string[]>>Required

retrieveInvite

Parameters

idstringRequired
sharedContextContext

Returns

PromisePromise<InviteDTO>Required

listInvites

Parameters

Returns

PromisePromise<InviteDTO[]>Required

listAndCountInvites

Parameters

Returns

PromisePromise<[InviteDTO[], number]>Required

createInvites

**createInvites**(data, sharedContext?): Promise&#60;[InviteDTO](types.UserTypes.InviteDTO.mdx)[]&#62;

Parameters

dataCreateInviteDTO[]Required
sharedContextContext

Returns

PromisePromise<InviteDTO[]>Required

**createInvites**(data, sharedContext?): Promise&#60;[InviteDTO](types.UserTypes.InviteDTO.mdx)&#62;

Parameters

dataCreateInviteDTORequired
sharedContextContext

Returns

PromisePromise<InviteDTO>Required

updateInvites

**updateInvites**(data, sharedContext?): Promise&#60;[InviteDTO](types.UserTypes.InviteDTO.mdx)[]&#62;

Parameters

dataUpdateInviteDTO[]Required
sharedContextContext

Returns

PromisePromise<InviteDTO[]>Required

**updateInvites**(data, sharedContext?): Promise&#60;[InviteDTO](types.UserTypes.InviteDTO.mdx)&#62;

Parameters

dataUpdateInviteDTORequired
sharedContextContext

Returns

PromisePromise<InviteDTO>Required

deleteInvites

Parameters

idsstring[]Required
sharedContextContext

Returns

PromisePromise<void>Required

softDeleteInvites

Type Parameters

TReturnableLinkableKeysstringRequired

Parameters

inviteIdsstring[]Required
configSoftDeleteReturn<TReturnableLinkableKeys>
sharedContextContext

Returns

PromisePromise<void | Record<TReturnableLinkableKeys, string[]>>Required

restoreInvites

Type Parameters

TReturnableLinkableKeysstringRequired

Parameters

inviteIdsstring[]Required
configRestoreReturn<TReturnableLinkableKeys>
sharedContextContext

Returns

PromisePromise<void | Record<TReturnableLinkableKeys, string[]>>Required
Was this section helpful?