Files
medusa-store/www/apps/docs/content/references/js-client/classes/internal-8.internal.CustomerGroupService.md
github-actions[bot] daea35fe73 chore(docs): Generated JS Client Reference (#5334)
Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

Co-authored-by: Shahed Nasser <27354907+shahednasser@users.noreply.github.com>
2023-10-10 17:47:07 +00:00

10 KiB

displayed_sidebar
displayed_sidebar
jsClientSidebar

Class: CustomerGroupService

internal.internal.CustomerGroupService

Hierarchy

Properties

__configModule__

Protected Optional Readonly __configModule__: Record<string, unknown>

Inherited from

TransactionBaseService.configModule

Defined in

packages/medusa/dist/interfaces/transaction-base-service.d.ts:5


__container__

Protected Readonly __container__: any

Inherited from

TransactionBaseService.container

Defined in

packages/medusa/dist/interfaces/transaction-base-service.d.ts:4


__moduleDeclaration__

Protected Optional Readonly __moduleDeclaration__: Record<string, unknown>

Inherited from

TransactionBaseService.moduleDeclaration

Defined in

packages/medusa/dist/interfaces/transaction-base-service.d.ts:6


customerGroupRepository_

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

Defined in

packages/medusa/dist/services/customer-group.d.ts:14


customerService_

Protected Readonly customerService_: CustomerService

Defined in

packages/medusa/dist/services/customer-group.d.ts:15


handleCreationFail

Private handleCreationFail: any

Defined in

packages/medusa/dist/services/customer-group.d.ts:76


manager_

Protected manager_: EntityManager

Inherited from

TransactionBaseService.manager_

Defined in

packages/medusa/dist/interfaces/transaction-base-service.d.ts:7


transactionManager_

Protected transactionManager_: undefined | EntityManager

Inherited from

TransactionBaseService.transactionManager_

Defined in

packages/medusa/dist/interfaces/transaction-base-service.d.ts:8

Accessors

activeManager_

Protected get activeManager_(): EntityManager

Returns

EntityManager

Inherited from

TransactionBaseService.activeManager_

Defined in

packages/medusa/dist/interfaces/transaction-base-service.d.ts:9

Methods

addCustomers

addCustomers(id, customerIds): Promise<CustomerGroup>

Add a batch of customers to a customer group at once

Parameters

Name Type Description
id string id of the customer group to add customers to
customerIds string | string[] customer id's to add to the group

Returns

Promise<CustomerGroup>

the customer group after insertion

Defined in

packages/medusa/dist/services/customer-group.d.ts:30


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

Name Type Description
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

packages/medusa/dist/interfaces/transaction-base-service.d.ts:24


create

create(group): Promise<CustomerGroup>

Creates a customer group with the provided data.

Parameters

Name Type Description
group DeepPartial<CustomerGroup> the customer group to create

Returns

Promise<CustomerGroup>

the result of the create operation

Defined in

packages/medusa/dist/services/customer-group.d.ts:23


delete

delete(groupId): Promise<void>

Remove customer group

Parameters

Name Type Description
groupId string id of the customer group to delete

Returns

Promise<void>

a promise

Defined in

packages/medusa/dist/services/customer-group.d.ts:45


list

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

List customer groups.

Parameters

Name Type Description
selector undefined | Selector<CustomerGroup> & { discount_condition_id?: string ; q?: string } the query object for find
config FindConfig<CustomerGroup> the config to be used for find

Returns

Promise<CustomerGroup[]>

the result of the find operation

Defined in

packages/medusa/dist/services/customer-group.d.ts:53


listAndCount

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

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

Parameters

Name Type Description
selector undefined | Selector<CustomerGroup> & { discount_condition_id?: string ; q?: string } the query object for find
config FindConfig<CustomerGroup> the config to be used for find

Returns

Promise<[CustomerGroup[], number]>

the result of the find operation

Defined in

packages/medusa/dist/services/customer-group.d.ts:64


removeCustomer

removeCustomer(id, customerIds): Promise<CustomerGroup>

Remove list of customers from a customergroup

Parameters

Name Type Description
id string id of the customer group from which the customers are removed
customerIds string | string[] id's of the customer to remove from group

Returns

Promise<CustomerGroup>

the customergroup with the provided id

Defined in

packages/medusa/dist/services/customer-group.d.ts:75


retrieve

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

Parameters

Name Type
customerGroupId string
config? Object

Returns

Promise<CustomerGroup>

Defined in

packages/medusa/dist/services/customer-group.d.ts:17


shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

Name Type
err Record<string, unknown> | { code: string }

Returns

boolean

Inherited from

TransactionBaseService.shouldRetryTransaction_

Defined in

packages/medusa/dist/interfaces/transaction-base-service.d.ts:12


update

update(customerGroupId, update): Promise<CustomerGroup>

Update a customer group.

Parameters

Name Type Description
customerGroupId string id of the customer group
update CustomerGroupUpdate customer group partial data

Returns

Promise<CustomerGroup>

resulting customer group

Defined in

packages/medusa/dist/services/customer-group.d.ts:38


withTransaction

withTransaction(transactionManager?): CustomerGroupService

Parameters

Name Type
transactionManager? EntityManager

Returns

CustomerGroupService

Inherited from

TransactionBaseService.withTransaction

Defined in

packages/medusa/dist/interfaces/transaction-base-service.d.ts:11