Skip to main content
Skip to main content

StoreService

internal.internal.StoreService

Provides layer to manipulate store settings.

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
currencyRepository_Repository<Currency>Required
eventBus_EventBusServiceRequired
manager_EntityManagerRequired
storeRepository_Repository<Store>Required
transactionManager_undefined | EntityManagerRequired

Accessors

activeManager_

Protected get activeManager_(): EntityManager

Returns

EntityManager

EntityManagerEntityManagerRequired

Inherited from

TransactionBaseService.activeManager_

Methods

addCurrency

addCurrency(code): Promise<Store>

Add a currency to the store

Parameters

codestringRequired
3 character ISO currency code

Returns

Promise<Store>

PromisePromise<Store>Required
result after update

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.

TResultobjectRequired
TErrorobjectRequired

Parameters

work(transactionManager: EntityManager) => Promise<TResult>Required
the transactional work to be done
isolationOrErrorHandlerIsolationLevel | (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>

PromisePromise<TResult>Required
the result of the transactional work

Inherited from

TransactionBaseService.atomicPhase_


create

create(): Promise<Store>

Creates a store if it doesn't already exist.

Returns

Promise<Store>

PromisePromise<Store>Required
The store.

getDefaultCurrency_

Protected getDefaultCurrency_(code): Partial<Currency>

Parameters

codestringRequired

Returns

Partial<Currency>

PartialPartial<Currency>Required

removeCurrency

removeCurrency(code): Promise<any>

Removes a currency from the store

Parameters

codestringRequired
3 character ISO currency code

Returns

Promise<any>

PromisePromise<any>Required
result after update

retrieve

retrieve(config?): Promise<Store>

Retrieve the store settings. There is always a maximum of one store.

Parameters

The config object from which the query will be built

Returns

Promise<Store>

PromisePromise<Store>Required
the store

shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

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

Returns

boolean

booleanboolean

Inherited from

TransactionBaseService.shouldRetryTransaction_


update

update(data): Promise<Store>

Updates a store

Parameters

dataUpdateStoreInputRequired
an object with the update values.

Returns

Promise<Store>

PromisePromise<Store>Required
resolves to the update result.

withTransaction

withTransaction(transactionManager?): StoreService

Parameters

transactionManagerEntityManager

Returns

StoreService

StoreServiceStoreServiceRequired

Inherited from

TransactionBaseService.withTransaction

Was this section helpful?