Skip to main content

Class: StoreService

Provides layer to manipulate store settings.

Hierarchy

Constructors

constructor

new StoreService(__namedParameters)

Parameters

NameType
__namedParametersInjectedDependencies

Overrides

TransactionBaseService<StoreService\>.constructor

Defined in

packages/medusa/src/services/store.ts:32

Properties

configModule

Protected Optional Readonly configModule: Record<string, unknown>

Inherited from

TransactionBaseService.configModule

Defined in

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


container

Protected Readonly container: unknown

Inherited from

TransactionBaseService.container

Defined in

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


currencyRepository_

Protected Readonly currencyRepository_: typeof CurrencyRepository

Defined in

packages/medusa/src/services/store.ts:29


eventBus_

Protected Readonly eventBus_: EventBusService

Defined in

packages/medusa/src/services/store.ts:30


manager_

Protected manager_: EntityManager

Overrides

TransactionBaseService.manager_

Defined in

packages/medusa/src/services/store.ts:25


storeRepository_

Protected Readonly storeRepository_: typeof StoreRepository

Defined in

packages/medusa/src/services/store.ts:28


transactionManager_

Protected transactionManager_: EntityManager

Overrides

TransactionBaseService.transactionManager_

Defined in

packages/medusa/src/services/store.ts:26

Methods

addCurrency

addCurrency(code): Promise<Store>

Add a currency to the store

Parameters

NameTypeDescription
codestring3 character ISO currency code

Returns

Promise<Store>

result after update

Defined in

packages/medusa/src/services/store.ts:210


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

packages/medusa/src/interfaces/transaction-base-service.ts:53


create

create(): Promise<Store>

Creates a store if it doesn't already exist.

Returns

Promise<Store>

The store.

Defined in

packages/medusa/src/services/store.ts:55


getDefaultCurrency_

Protected getDefaultCurrency_(code): Partial<Currency>

Parameters

NameType
codestring

Returns

Partial<Currency>

Defined in

packages/medusa/src/services/store.ts:104


removeCurrency

removeCurrency(code): Promise<any>

Removes a currency from the store

Parameters

NameTypeDescription
codestring3 character ISO currency code

Returns

Promise<any>

result after update

Defined in

packages/medusa/src/services/store.ts:254


retrieve

retrieve(config?): Promise<Store>

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

Parameters

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

Returns

Promise<Store>

the store

Defined in

packages/medusa/src/services/store.ts:91


shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

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

Returns

boolean

Inherited from

TransactionBaseService.shouldRetryTransaction_

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:34


update

update(data): Promise<Store>

Updates a store

Parameters

NameTypeDescription
dataUpdateStoreInputan object with the update values.

Returns

Promise<Store>

resolves to the update result.

Defined in

packages/medusa/src/services/store.ts:120


withTransaction

withTransaction(transactionManager?): StoreService

Parameters

NameType
transactionManager?EntityManager

Returns

StoreService

Inherited from

TransactionBaseService.withTransaction

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:16