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

ICustomerModuleService

The main service interface for the Customer Module.

Methods

retrieve

This method retrieves a customer by its ID.

Example

A simple example that retrieves a customer by its ID:

const customer =
await customerModuleService.retrieve("cus_123")

To specify relations that should be retrieved:

const customer = await customerModuleService.retrieve(
"cus_123",
{
relations: ["groups"],
}
)

Parameters

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

Returns

PromisePromise<CustomerDTO>Required
The retrieved customer.

create

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

This method creates customers.

Example

const customers = await customerModuleService.create([
{
email: "john@smith.com",
first_name: "John",
last_name: "Smith",
},
])

Parameters

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

Returns

PromisePromise<CustomerDTO[]>Required
The created customers.

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

This method creates a customer.

Example

const customer = await customerModuleService.create({
email: "john@smith.com",
first_name: "John",
last_name: "Smith",
})

Parameters

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

Returns

PromisePromise<CustomerDTO>Required
The created customer.

update

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

This method updates an existing customer.

Example

const customer = await customerModuleService.update(
"cus_123",
{
first_name: "Matt",
}
)

Parameters

customerIdstringRequired
The customer's ID.
The updatable fields of a customer.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<CustomerDTO>Required
The updated customer.

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

This method updates existing customers.

Example

const customers = await customerModuleService.update(
["cus_123", "cus_321"],
{
company_name: "Acme",
}
)

Parameters

customerIdsstring[]Required
The IDs of customers to update.
The attributes to update in the customers.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<CustomerDTO[]>Required
The updated customers.

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

This method updates existing customers.

Example

const customers = await customerModuleService.update(
{ company_name: "Acme" },
{
company_name: "Acme Inc.",
}
)

Parameters

selectorFilterableCustomerPropsRequired
The filters that specify which API keys should be updated.
The attributes to update in the customers.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<CustomerDTO[]>Required
The updated customers.

delete

**delete**(customerId, sharedContext?): Promise&#60;void&#62;

This method deletes a customer by its ID.

Example

await customerModuleService.delete("cus_123")

Parameters

customerIdstringRequired
The customer's ID.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<void>Required
Resolves when the customer is deleted successfully.

**delete**(customerIds, sharedContext?): Promise&#60;void&#62;

This method deletes customers by their IDs.

Example

await customerModuleService.delete(["cus_123", "cus_321"])

Parameters

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

Returns

PromisePromise<void>Required
Resolves when the customers are deleted successfully.

**delete**(selector, sharedContext?): Promise&#60;void&#62;

This method deletes a customer matching the specified filters.

Example

await customerModuleService.delete({
id: ["cus_123"],
})

Parameters

selectorFilterableCustomerPropsRequired
The filters that specify which customers should be deleted.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<void>Required
Resolves when the customers are deleted successfully.

createCustomerGroup

**createCustomerGroup**(data, sharedContext?): Promise&#60;[CustomerGroupDTO](types.CustomerTypes.CustomerGroupDTO.mdx)[]&#62;

This method creates customer groups.

Example

const customerGroup =
await customerModuleService.createCustomerGroup([
{
name: "VIP",
},
])

Parameters

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

Returns

PromisePromise<CustomerGroupDTO[]>Required
The created customer groups.

**createCustomerGroup**(data, sharedContext?): Promise&#60;[CustomerGroupDTO](types.CustomerTypes.CustomerGroupDTO.mdx)&#62;

This method creates a customer group.

Example

const customerGroup =
await customerModuleService.createCustomerGroup({
name: "VIP",
})

Parameters

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

Returns

PromisePromise<CustomerGroupDTO>Required
The created customer group.

retrieveCustomerGroup

This method retrieves a customer group by its ID.

Example

const customerGroup =
await customerModuleService.retrieve("cusgroup_123")

Parameters

groupIdstringRequired
The customer group's ID.
The configurations determining how the customer group is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a customer group.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<CustomerGroupDTO>Required
The retrieved customer group.

updateCustomerGroups

**updateCustomerGroups**(groupId, data, sharedContext?): Promise&#60;[CustomerGroupDTO](types.CustomerTypes.CustomerGroupDTO.mdx)&#62;

This method updates an existing customer group.

Example

const customerGroup =
await customerModuleService.updateCustomerGroups(
"cusgroup_123",
{
name: "Very Important",
}
)

Parameters

groupIdstringRequired
The group's ID.
The attributes to update in the customer group.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<CustomerGroupDTO>Required
The updated customer group.

**updateCustomerGroups**(groupIds, data, sharedContext?): Promise&#60;[CustomerGroupDTO](types.CustomerTypes.CustomerGroupDTO.mdx)[]&#62;

This method updates existing customer groups.

Example

const customerGroups =
await customerModuleService.updateCustomerGroups(
["cusgroup_123", "cusgroup_321"],
{
name: "Very Important",
}
)

Parameters

groupIdsstring[]Required
The IDs of customer groups.
The attributes to update in the customer groups.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<CustomerGroupDTO[]>Required
The updated customer groups.

**updateCustomerGroups**(selector, data, sharedContext?): Promise&#60;[CustomerGroupDTO](types.CustomerTypes.CustomerGroupDTO.mdx)[]&#62;

This method updates existing customer groups.

Example

const customerGroups =
await customerModuleService.updateCustomerGroups(
{
name: "VIP",
},
{
name: "Very Important",
}
)

Parameters

The filters that specify which customer groups should be updates.
The attributes to update in the customer groups.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<CustomerGroupDTO[]>Required
The updated customer groups.

deleteCustomerGroups

**deleteCustomerGroups**(groupId, sharedContext?): Promise&#60;void&#62;

This method deletes a customer group by its ID.

Example

await customerModuleService.deleteCustomerGroups(
"cusgroup_123"
)

Parameters

groupIdstringRequired
The customer group's ID.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<void>Required
Resolves when the customer group is deleted successfully.

**deleteCustomerGroups**(groupIds, sharedContext?): Promise&#60;void&#62;

This method deletes customer groups by their IDs.

Example

await customerModuleService.deleteCustomerGroups([
"cusgroup_123",
"cusgroup_321",
])

Parameters

groupIdsstring[]Required
The IDs of customer groups.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<void>Required
Resolves when the customer groups are deleted successfully.

**deleteCustomerGroups**(selector, sharedContext?): Promise&#60;void&#62;

This method deletes customer groups matching the specified filters.

Example

await customerModuleService.deleteCustomerGroups({
name: "VIP",
})

Parameters

The filters that specify which customer group 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 customer groups are deleted successfully.

addCustomerToGroup

**addCustomerToGroup**(groupCustomerPair, sharedContext?): Promise&#60;&#123; id: string &#125;&#62;

This method adds a customer to a group.

Example

const customerGroupCustomerId =
await customerModuleService.addCustomerToGroup({
customer_id: "cus_123",
customer_group_id: "cus_321",
})

Parameters

groupCustomerPairGroupCustomerPairRequired
The details of the customer and the group it should be added to.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<object>Required
The ID of the relation between the customer and the group.

**addCustomerToGroup**(groupCustomerPairs, sharedContext?): Promise&#60;&#123; id: string &#125;[]&#62;

This method adds customers to groups.

Example

const customerGroupCustomerIds =
await customerModuleService.addCustomerToGroup([
{
customer_id: "cus_123",
customer_group_id: "cus_321",
},
])

Parameters

groupCustomerPairsGroupCustomerPair[]Required
A list of items, each being the details of a customer and the group it should be added to.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<object[]>Required
The IDs of the relations between each of the customer and group pairs.

removeCustomerFromGroup

**removeCustomerFromGroup**(groupCustomerPair, sharedContext?): Promise&#60;void&#62;

This method removes a customer from a group.

Example

await customerModuleService.removeCustomerFromGroup({
customer_id: "cus_123",
customer_group_id: "cus_321",
})

Parameters

groupCustomerPairGroupCustomerPairRequired
The details of the customer and the group it should be removed from.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<void>Required
Resolves when the customer is removed from the group successfully.

**removeCustomerFromGroup**(groupCustomerPairs, sharedContext?): Promise&#60;void&#62;

This method removes customers from groups.

Example

await customerModuleService.removeCustomerFromGroup([
{
customer_id: "cus_123",
customer_group_id: "cus_321",
},
])

Parameters

groupCustomerPairsGroupCustomerPair[]Required
A list of items, each being the details of a customer and the group it should be removed from.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<void>Required
Resolves when the customers are removed from the groups successfully.

addAddresses

**addAddresses**(addresses, sharedContext?): Promise&#60;[CustomerAddressDTO](types.CustomerTypes.CustomerAddressDTO.mdx)[]&#62;

This method adds addresses to customers.

Example

const addresses = await customerModuleService.addAddresses([
{
customer_id: "cus_123",
address_name: "Home",
address_1: "432 Stierlin Rd",
city: "Mountain View",
country_code: "us",
},
])

Parameters

addressesCreateCustomerAddressDTO[]Required
A list of items, each being the details of the address to add to a customer.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<CustomerAddressDTO[]>Required
The list of created addresses.

**addAddresses**(address, sharedContext?): Promise&#60;[CustomerAddressDTO](types.CustomerTypes.CustomerAddressDTO.mdx)&#62;

This method adds an address to a customer.

Example

const address = await customerModuleService.addAddresses({
customer_id: "cus_123",
address_name: "Home",
address_1: "432 Stierlin Rd",
city: "Mountain View",
country_code: "us",
})

Parameters

The details of the address to add to a customer.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<CustomerAddressDTO>Required
The created address.

updateAddresses

**updateAddresses**(addressId, data, sharedContext?): Promise&#60;[CustomerAddressDTO](types.CustomerTypes.CustomerAddressDTO.mdx)&#62;

This method updates an address.

Example

const address = await customerModuleService.updateAddresses(
"cuaddr_123",
{
first_name: "John",
last_name: "Smith",
}
)

Parameters

addressIdstringRequired
The address's ID.
The attributes to update in the address.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<CustomerAddressDTO>Required
The updated address.

**updateAddresses**(addressIds, data, sharedContext?): Promise&#60;[CustomerAddressDTO](types.CustomerTypes.CustomerAddressDTO.mdx)[]&#62;

This method updates existing addresses.

Example

const addresses = await customerModuleService.updateAddresses(
["cuaddr_123", "cuaddr_321"],
{
first_name: "John",
last_name: "Smith",
}
)

Parameters

addressIdsstring[]Required
The IDs of addresses to update.
The attributes to update in the addresses.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<CustomerAddressDTO[]>Required
The updated addresses.

**updateAddresses**(selector, data, sharedContext?): Promise&#60;[CustomerAddressDTO](types.CustomerTypes.CustomerAddressDTO.mdx)[]&#62;

This method updates existing addresses matching the specified filters.

Example

const addresses = await customerModuleService.updateAddresses(
{ first_name: "John" },
{
last_name: "Smith",
}
)

Parameters

The filters that specify which address should be updated.
The attributes to update in the addresses.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<CustomerAddressDTO[]>Required
The updated addresses.

deleteAddresses

**deleteAddresses**(addressId, sharedContext?): Promise&#60;void&#62;

This method deletes an address by its ID.

Example

await customerModuleService.deleteAddresses("cuaddr_123")

Parameters

addressIdstringRequired
The address's ID.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<void>Required
Resolves when the address is deleted successfully.

**deleteAddresses**(addressIds, sharedContext?): Promise&#60;void&#62;

This method deletes addresses by their IDs.

Example

await customerModuleService.deleteAddresses([
"cuaddr_123",
"cuaddr_321",
])

Parameters

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

Returns

PromisePromise<void>Required
Resolves when the addresses are deleted successfully.

**deleteAddresses**(selector, sharedContext?): Promise&#60;void&#62;

This method deletes addresses matching the specified filters.

Example

await customerModuleService.deleteAddresses({
first_name: "John",
last_name: "Smith",
})

Parameters

The filters that specify which addresses should be deleted.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<void>Required
Resolves when the addresses are deleted successfully.

listAddresses

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

Example

To retrieve a list of addresses using their IDs:

const addresses = await customerModuleService.listAddresses({
id: ["cuaddr_123", "cuaddr_321"],
})

To specify relations that should be retrieved within the addresses:

const addresses = await customerModuleService.listAddresses(
{
id: ["cuaddr_123", "cuaddr_321"],
},
{
relations: ["customer"],
}
)

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

const addresses = await customerModuleService.listAddresses(
{
id: ["cuaddr_123", "cuaddr_321"],
},
{
relations: ["customer"],
take: 20,
skip: 2,
}
)

Parameters

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

Returns

PromisePromise<CustomerAddressDTO[]>Required
The list of addresses.

listAndCountAddresses

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

Example

To retrieve a list of addresses using their IDs:

const [addresses, count] =
await customerModuleService.listAndCountAddresses({
id: ["cuaddr_123", "cuaddr_321"],
})

To specify relations that should be retrieved within the addresses:

const [addresses, count] =
await customerModuleService.listAndCountAddresses(
{
id: ["cuaddr_123", "cuaddr_321"],
},
{
relations: ["customer"],
}
)

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

const [addresses, count] =
await customerModuleService.listAndCountAddresses(
{
id: ["cuaddr_123", "cuaddr_321"],
},
{
relations: ["customer"],
take: 20,
skip: 2,
}
)

Parameters

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

Returns

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

listCustomerGroupCustomers

This method retrieves a paginated list of relations between customer and groups based on optional filters and configuration.

Example

To retrieve a list of customer-group relations using their IDs:

const customerGroupCustomerRels =
await customerModuleService.listCustomerGroupCustomers({
id: ["cusgc_123"],
})

To specify relations that should be retrieved within the customer-group relations:

const customerGroupCustomerRels =
await customerModuleService.listCustomerGroupCustomers(
{
id: ["cusgc_123"],
},
{
relations: ["customer", "customer_group"],
}
)

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

const customerGroupCustomerRels =
await customerModuleService.listCustomerGroupCustomers(
{
id: ["cusgc_123"],
},
{
relations: ["customer", "customer_group"],
take: 20,
skip: 2,
}
)

Parameters

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

Returns

PromisePromise<CustomerGroupCustomerDTO[]>Required
The list of customer-group relations.

list

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

Example

To retrieve a list of customers using their IDs:

const customers = await customerModuleService.list({
id: ["cus_123", "cus_321"],
})

To specify relations that should be retrieved within the customers:

const customers = await customerModuleService.list(
{
id: ["cus_123", "cus_321"],
},
{
relations: ["groups"],
}
)

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

const customers = await customerModuleService.list(
{
id: ["cus_123", "cus_321"],
},
{
relations: ["groups"],
take: 20,
skip: 2,
}
)

Parameters

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

Returns

PromisePromise<CustomerDTO[]>Required
The list of customers.

listAndCount

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

Example

To retrieve a list of customers using their IDs:

const [customers, count] = await customerModuleService.list({
id: ["cus_123", "cus_321"],
})

To specify relations that should be retrieved within the customers:

const [customers, count] = await customerModuleService.list(
{
id: ["cus_123", "cus_321"],
},
{
relations: ["groups"],
}
)

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

const [customers, count] = await customerModuleService.list(
{
id: ["cus_123", "cus_321"],
},
{
relations: ["groups"],
take: 20,
skip: 2,
}
)

Parameters

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

Returns

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

listCustomerGroups

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

Example

To retrieve a list of customer groups using their IDs:

const customerGroups =
await customerModuleService.listCustomerGroups({
id: ["cusgroup_123", "cusgroup_321"],
})

To specify relations that should be retrieved within the customer groups:

const customerGroups =
await customerModuleService.listCustomerGroups(
{
id: ["cusgroup_123", "cusgroup_321"],
},
{
relations: ["customers"],
}
)

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

const customerGroups =
await customerModuleService.listCustomerGroups(
{
id: ["cusgroup_123", "cusgroup_321"],
},
{
relations: ["customers"],
take: 20,
skip: 2,
}
)

Parameters

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

Returns

PromisePromise<CustomerGroupDTO[]>Required
The list of customer groups.

listAndCountCustomerGroups

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

Example

To retrieve a list of customer groups using their IDs:

const [customerGroups, count] =
await customerModuleService.listCustomerGroups({
id: ["cusgroup_123", "cusgroup_321"],
})

To specify relations that should be retrieved within the customer groups:

const [customerGroups, count] =
await customerModuleService.listCustomerGroups(
{
id: ["cusgroup_123", "cusgroup_321"],
},
{
relations: ["customers"],
}
)

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

const [customerGroups, count] =
await customerModuleService.listCustomerGroups(
{
id: ["cusgroup_123", "cusgroup_321"],
},
{
relations: ["customers"],
take: 20,
skip: 2,
}
)

Parameters

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

Returns

PromisePromise<[CustomerGroupDTO[], number]>Required
The list of customer groups along with their total count.

softDelete

This method soft deletes customers by their IDs.

Example

await customerModuleService.softDelete(["cus_123"])

Type Parameters

TReturnableLinkableKeysstringRequired

Parameters

customerIdsstring[]Required
The IDs of customers.
configSoftDeleteReturn<TReturnableLinkableKeys>
An object that is used to specify an entity's related entities that should be soft-deleted when the main entity is soft-deleted.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<void | Record<TReturnableLinkableKeys, string[]>>Required
An object that includes the IDs of related records that were also soft deleted, such as the ID of the associated address. The object's keys are the ID attribute names of the customer entity's relations, such as address_id, and its value is an array of strings, each being the ID of a record associated with the customer through this relation, such as the IDs of associated address. If there are no related records, the promise resolves to void.

restore

This method restores soft deleted customer by their IDs.

Example

await customerModuleService.restore(["cus_123"])

Type Parameters

TReturnableLinkableKeysstringRequired

Parameters

customerIdsstring[]Required
The IDs of customers.
configRestoreReturn<TReturnableLinkableKeys>
Configurations determining which relations to restore along with each of the customer. You can pass to its returnLinkableKeys property any of the customer's relation attribute names, such as groups.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<void | Record<TReturnableLinkableKeys, string[]>>Required
An object that includes the IDs of related records that were restored. If there are no related records restored, the promise resolves to void.

softDeleteCustomerGroups

This method soft deletes customer groups by their IDs.

Example

await customerModuleService.softDeleteCustomerGroups([
"cusgroup_123",
])

Type Parameters

TReturnableLinkableKeysstringRequired

Parameters

groupIdsstring[]Required
The IDs of customer groups.
configSoftDeleteReturn<TReturnableLinkableKeys>
An object that is used to specify an entity's related entities that should be soft-deleted when the main entity is soft-deleted.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<void | Record<TReturnableLinkableKeys, string[]>>Required
An object that includes the IDs of related records that were also soft deleted. If there are no related records, the promise resolves to void.

restoreCustomerGroups

This method restores a soft deleted customer group by its IDs.

Example

await customerModuleService.restoreCustomerGroups([
"cusgroup_123",
])

Type Parameters

TReturnableLinkableKeysstringRequired

Parameters

groupIdsstring[]Required
The IDs of customer groups.
configRestoreReturn<TReturnableLinkableKeys>
Configurations determining which relations to restore along with each of the customer groups. You can pass to its returnLinkableKeys property any of the customer group's relation attribute names, such as customers.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<void | Record<TReturnableLinkableKeys, string[]>>Required
An object that includes the IDs of related records that were restored. If there are no related records restored, the promise resolves to void.
Was this section helpful?