Skip to main content
Skip to main content

StoreService

Provides layer to manipulate store settings.

Constructors

constructor

**new StoreService**(«destructured»)

Parameters

__namedParametersInjectedDependenciesRequired

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

Methods

addCurrency

**addCurrency**(code): Promise&#60;[Store](/references/services/classes/Store)&#62;

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_**<TypeParameter TResult, TypeParameter TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise&#60;TResult&#62;

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

create

**create**(): Promise&#60;[Store](/references/services/classes/Store)&#62;

Creates a store if it doesn't already exist.

Returns

Promise<Store>

PromisePromise<Store>Required
The store.

getDefaultCurrency_

Protected **getDefaultCurrency_**(code): [Partial](/references/services/types/Partial)&#60;[Currency](/references/services/classes/Currency)&#62;

Parameters

codestringRequired

Returns

Partial<Currency>

PartialPartial<Currency>Required

removeCurrency

**removeCurrency**(code): Promise&#60;any&#62;

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&#60;[Store](/references/services/classes/Store)&#62;

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

Parameters

configFindConfig<Store>Required
The config object from which the query will be built

Default: {}

Returns

Promise<Store>

PromisePromise<Store>Required
the store

shouldRetryTransaction_

Protected **shouldRetryTransaction_**(err): boolean

Parameters

errRecord<string, unknown> | &#123; code: string &#125;Required

Returns

boolean

booleanboolean

update

**update**(data): Promise&#60;[Store](/references/services/classes/Store)&#62;

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](/references/services/classes/StoreService)

Parameters

transactionManagerEntityManager

Returns

StoreService

StoreServiceStoreServiceRequired
Was this section helpful?