Skip to main content

Class: StoreService

Provides layer to manipulate store settings.

Hierarchy

  • TransactionBaseService

    StoreService

Constructors

constructor

new StoreService(__namedParameters)

Parameters

NameType
__namedParametersInjectedDependencies

Overrides

TransactionBaseService.constructor

Defined in

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

Properties

__configModule__

Protected Optional Readonly __configModule__: Record<string, unknown>

Inherited from

TransactionBaseService.__configModule__

Defined in

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


__container__

Protected Readonly __container__: any

Inherited from

TransactionBaseService.__container__

Defined in

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


__moduleDeclaration__

Protected Optional Readonly __moduleDeclaration__: Record<string, unknown>

Inherited from

TransactionBaseService.__moduleDeclaration__

Defined in

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


currencyRepository_

Protected Readonly currencyRepository_: typeof CurrencyRepository

Defined in

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


eventBus_

Protected Readonly eventBus_: EventBusService

Defined in

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


manager_

Protected manager_: EntityManager

Overrides

TransactionBaseService.manager_

Defined in

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


storeRepository_

Protected Readonly storeRepository_: typeof StoreRepository

Defined in

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


transactionManager_

Protected transactionManager_: EntityManager

Overrides

TransactionBaseService.transactionManager_

Defined in

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

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:204


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:50


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:49


getDefaultCurrency_

Protected getDefaultCurrency_(code): Partial<Currency>

Parameters

NameType
codestring

Returns

Partial<Currency>

Defined in

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


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:248


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:85


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:31


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:114


withTransaction

withTransaction(transactionManager?): StoreService

Parameters

NameType
transactionManager?EntityManager

Returns

StoreService

Inherited from

TransactionBaseService.withTransaction

Defined in

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