Skip to main content

SettingsStoreService

The SettingsStoreService provides a flexible settings storage system with support for scoping, permissions, and validation. It allows plugins and the core system to store and retrieve configuration data with fine-grained control over access and isolation.

Usage

Values are automatically scoped according to their field configuration:

Example

Ts
Signature
  • Implements: OnModuleInit

constructor

method(connection: TransactionalConnection, moduleRef: ModuleRef, configService: ConfigService) => SettingsStoreService

onModuleInit

method() =>

register

method(registration: SettingsStoreRegistration) => void

Register settings store fields. This is typically called during application bootstrap when processing the VendureConfig.

get

method(ctx: RequestContext, key: string) => Promise<T | undefined>

Get a value for the specified key. The value is automatically scoped according to the field's scope configuration.

get

method(key: string, ctx: RequestContext) => Promise<T | undefined>

get

method(keyOrCtx: string | RequestContext, ctxOrKey: RequestContext | string) => Promise<T | undefined>

getMany

method(ctx: RequestContext, keys: string[]) => Promise<Record<string, JsonCompatible<any>>>

Get multiple values efficiently. Each key is scoped according to its individual field configuration.

getMany

method(keys: string[], ctx: RequestContext) => Promise<Record<string, JsonCompatible<any>>>

getMany

method(keysOrCtx: string[] | RequestContext, ctxOrKeys: RequestContext | string[]) => Promise<Record<string, JsonCompatible<any>>>

set

method(ctx: RequestContext, key: string, value: T) => Promise<SetSettingsStoreValueResult>

Set a value for the specified key with structured result feedback. This version returns detailed information about the success or failure of the operation instead of throwing errors.

set

method(key: string, value: T, ctx: RequestContext) => Promise<SetSettingsStoreValueResult>

set

method(keyOrCtx: string | RequestContext, keyOrValue: string | T, ctxOrValue: RequestContext | T) => Promise<SetSettingsStoreValueResult>

setMany

method(ctx: RequestContext, values: Record<string, JsonCompatible<any>>) => Promise<SetSettingsStoreValueResult[]>

Set multiple values with structured result feedback for each operation. This method will not throw errors but will return detailed results for each key-value pair.

setMany

method(values: Record<string, JsonCompatible<any>>, ctx: RequestContext) => Promise<SetSettingsStoreValueResult[]>

setMany

method(valuesOrCtx: Record<string, JsonCompatible<any>> | RequestContext, ctxOrValues: RequestContext | Record<string, JsonCompatible<any>>) => Promise<SetSettingsStoreValueResult[]>

getFieldDefinition

method(key: string) => SettingsStoreFieldConfig | undefined

Get the field configuration for a key.

getAllFieldDefinitions

method() => Array<{ key: string; config: SettingsStoreFieldConfig }>v3.6.0

Returns all registered field definitions with their full keys.

getScopeType

method(fieldConfig: SettingsStoreFieldConfig) => SettingsStoreScopeTypev3.6.0

Determines the scope type of a field by comparing its scope function reference to the pre-built SettingsStoreScopes functions.

validateValue

method(key: string, value: any, ctx: RequestContext) => Promise<string | void>

Validate a value against its field definition.

findOrphanedEntries

Find orphaned settings store entries that no longer have corresponding field definitions.

cleanupOrphanedEntries

Clean up orphaned settings store entries from the database.

hasPermission

method(ctx: RequestContext, key: string) => boolean

Check if the current user has permission to access a field. This is not called internally in the get and set methods, so should be used by any methods which are exposing these methods via the GraphQL APIs.

hasReadPermission

method(ctx: RequestContext, key: string) => booleanv3.5.0

Check if the current user has permission to read a field.

hasWritePermission

method(ctx: RequestContext, key: string) => booleanv3.5.0

Check if the current user has permission to write a field.

isReadonly

method(key: string) => boolean

Returns true if the settings field has the readonly: true configuration.

Was this chapter helpful?
Report Issue
Edited Mar 6, 2026ยทEdit this page