Skip to main content

Class: CustomerGroupService

Hierarchy

  • TransactionBaseService

    CustomerGroupService

Constructors

constructor

new CustomerGroupService(__namedParameters)

Parameters

NameType
__namedParametersCustomerGroupConstructorProps

Overrides

TransactionBaseService.constructor

Defined in

medusa/src/services/customer-group.ts:24

Properties

__configModule__

Protected Optional Readonly __configModule__: Record<string, unknown>

Inherited from

TransactionBaseService.__configModule__

Defined in

medusa/src/interfaces/transaction-base-service.ts:14


__container__

Protected Readonly __container__: any

Inherited from

TransactionBaseService.__container__

Defined in

medusa/src/interfaces/transaction-base-service.ts:13


__moduleDeclaration__

Protected Optional Readonly __moduleDeclaration__: Record<string, unknown>

Inherited from

TransactionBaseService.__moduleDeclaration__

Defined in

medusa/src/interfaces/transaction-base-service.ts:15


customerGroupRepository_

Protected Readonly customerGroupRepository_: Repository<CustomerGroup> & { addCustomers: (groupId: string, customerIds: string[]) => Promise<CustomerGroup> ; findWithRelationsAndCount: (relations: FindOptionsRelations<CustomerGroup>, idsOrOptionsWithoutRelations: FindWithoutRelationsOptions) => Promise<[CustomerGroup[], number]> ; removeCustomers: (groupId: string, customerIds: string[]) => Promise<DeleteResult> }

Defined in

medusa/src/services/customer-group.ts:21


customerService_

Protected Readonly customerService_: CustomerService

Defined in

medusa/src/services/customer-group.ts:22


manager_

Protected manager_: EntityManager

Inherited from

TransactionBaseService.manager_

Defined in

medusa/src/interfaces/transaction-base-service.ts:5


transactionManager_

Protected transactionManager_: undefined | EntityManager

Inherited from

TransactionBaseService.transactionManager_

Defined in

medusa/src/interfaces/transaction-base-service.ts:6

Accessors

activeManager_

Protected get activeManager_(): EntityManager

Returns

EntityManager

Inherited from

TransactionBaseService.activeManager_

Defined in

medusa/src/interfaces/transaction-base-service.ts:8

Methods

addCustomers

addCustomers(id, customerIds): Promise<CustomerGroup>

Add a batch of customers to a customer group at once

Parameters

NameTypeDescription
idstringid of the customer group to add customers to
customerIdsstring | string[]customer id's to add to the group

Returns

Promise<CustomerGroup>

the customer group after insertion

Defined in

medusa/src/services/customer-group.ts:89


atomicPhase_

Protected atomicPhase_<TResult, TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise<TResult>

Wraps some work within a transactional block. If the service already has a transaction manager attached this will be reused, otherwise a new transaction manager is created.

Type parameters

Name
TResult
TError

Parameters

NameTypeDescription
work(transactionManager: EntityManager) => Promise<TResult>the transactional work to be done
isolationOrErrorHandler?IsolationLevel | (error: TError) => Promise<void | TResult>the isolation level to be used for the work.
maybeErrorHandlerOrDontFail?(error: TError) => Promise<void | TResult>Potential error handler

Returns

Promise<TResult>

the result of the transactional work

Inherited from

TransactionBaseService.atomicPhase_

Defined in

medusa/src/interfaces/transaction-base-service.ts:56


create

create(group): Promise<CustomerGroup>

Creates a customer group with the provided data.

Parameters

NameTypeDescription
groupDeepPartial<CustomerGroup>the customer group to create

Returns

Promise<CustomerGroup>

the result of the create operation

Defined in

medusa/src/services/customer-group.ts:65


delete

delete(groupId): Promise<void>

Remove customer group

Parameters

NameTypeDescription
groupIdstringid of the customer group to delete

Returns

Promise<void>

a promise

Defined in

medusa/src/services/customer-group.ts:153


handleCreationFail

Private handleCreationFail(id, ids, error): Promise<never>

Parameters

NameType
idstring
idsstring[]
errorany

Returns

Promise<never>

Defined in

medusa/src/services/customer-group.ts:257


list

list(selector?, config): Promise<CustomerGroup[]>

List customer groups.

Parameters

NameTypeDescription
selectorSelector<CustomerGroup> & { discount_condition_id?: string ; q?: string }the query object for find
configFindConfig<CustomerGroup>the config to be used for find

Returns

Promise<CustomerGroup[]>

the result of the find operation

Defined in

medusa/src/services/customer-group.ts:176


listAndCount

listAndCount(selector?, config): Promise<[CustomerGroup[], number]>

Retrieve a list of customer groups and total count of records that match the query.

Parameters

NameTypeDescription
selectorSelector<CustomerGroup> & { discount_condition_id?: string ; q?: string }the query object for find
configFindConfig<CustomerGroup>the config to be used for find

Returns

Promise<[CustomerGroup[], number]>

the result of the find operation

Defined in

medusa/src/services/customer-group.ts:194


removeCustomer

removeCustomer(id, customerIds): Promise<CustomerGroup>

Remove list of customers from a customergroup

Parameters

NameTypeDescription
idstringid of the customer group from which the customers are removed
customerIdsstring | string[]id's of the customer to remove from group

Returns

Promise<CustomerGroup>

the customergroup with the provided id

Defined in

medusa/src/services/customer-group.ts:236


retrieve

retrieve(customerGroupId, config?): Promise<CustomerGroup>

Parameters

NameType
customerGroupIdstring
configObject

Returns

Promise<CustomerGroup>

Defined in

medusa/src/services/customer-group.ts:35


shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

NameType
errRecord<string, unknown> | { code: string }

Returns

boolean

Inherited from

TransactionBaseService.shouldRetryTransaction_

Defined in

medusa/src/interfaces/transaction-base-service.ts:37


update

update(customerGroupId, update): Promise<CustomerGroup>

Update a customer group.

Parameters

NameTypeDescription
customerGroupIdstringid of the customer group
updateCustomerGroupUpdatecustomer group partial data

Returns

Promise<CustomerGroup>

resulting customer group

Defined in

medusa/src/services/customer-group.ts:120


withTransaction

withTransaction(transactionManager?): CustomerGroupService

Parameters

NameType
transactionManager?EntityManager

Returns

CustomerGroupService

Inherited from

TransactionBaseService.withTransaction

Defined in

medusa/src/interfaces/transaction-base-service.ts:20