---
title: "SettingsStoreService"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/service/helpers/settings-store/settings-store.service.ts" sourceLine="50" packageName="@vendure/core" since="3.4.0" />

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
// In a service
const userTheme = await this.settingsStoreService.get('dashboard.theme', ctx);
await this.settingsStoreService.set('dashboard.theme', 'dark', ctx);

// Get multiple values
const settings = await this.settingsStoreService.getMany([
  'dashboard.theme',
  'dashboard.tableFilters'
], ctx);
```

```ts title="Signature"
class SettingsStoreService implements OnModuleInit {
    constructor(connection: TransactionalConnection, moduleRef: ModuleRef, configService: ConfigService)
    onModuleInit() => ;
    register(registration: SettingsStoreRegistration) => void;
    get(ctx: RequestContext, key: string) => Promise<T | undefined>;
    get(key: string, ctx: RequestContext) => Promise<T | undefined>;
    get(keyOrCtx: string | RequestContext, ctxOrKey: RequestContext | string) => Promise<T | undefined>;
    getMany(ctx: RequestContext, keys: string[]) => Promise<Record<string, JsonCompatible<any>>>;
    getMany(keys: string[], ctx: RequestContext) => Promise<Record<string, JsonCompatible<any>>>;
    getMany(keysOrCtx: string[] | RequestContext, ctxOrKeys: RequestContext | string[]) => Promise<Record<string, JsonCompatible<any>>>;
    set(ctx: RequestContext, key: string, value: T) => Promise<SetSettingsStoreValueResult>;
    set(key: string, value: T, ctx: RequestContext) => Promise<SetSettingsStoreValueResult>;
    set(keyOrCtx: string | RequestContext, keyOrValue: string | T, ctxOrValue: RequestContext | T) => Promise<SetSettingsStoreValueResult>;
    setMany(ctx: RequestContext, values: Record<string, JsonCompatible<any>>) => Promise<SetSettingsStoreValueResult[]>;
    setMany(values: Record<string, JsonCompatible<any>>, ctx: RequestContext) => Promise<SetSettingsStoreValueResult[]>;
    setMany(valuesOrCtx: Record<string, JsonCompatible<any>> | RequestContext, ctxOrValues: RequestContext | Record<string, JsonCompatible<any>>) => Promise<SetSettingsStoreValueResult[]>;
    getFieldDefinition(key: string) => SettingsStoreFieldConfig | undefined;
    validateValue(key: string, value: any, ctx: RequestContext) => Promise<string | void>;
    findOrphanedEntries(options: CleanupOrphanedSettingsStoreEntriesOptions = {}) => Promise<OrphanedSettingsStoreEntry[]>;
    cleanupOrphanedEntries(options: CleanupOrphanedSettingsStoreEntriesOptions = {}) => Promise<CleanupOrphanedSettingsStoreEntriesResult>;
    hasPermission(ctx: RequestContext, key: string) => boolean;
    hasReadPermission(ctx: RequestContext, key: string) => boolean;
    hasWritePermission(ctx: RequestContext, key: string) => boolean;
    isReadonly(key: string) => boolean;
}
```
* Implements: OnModuleInit



<div className="members-wrapper">

### constructor

<MemberInfo kind="method" type={`(connection: <a href='/reference/typescript-api/data-access/transactional-connection#transactionalconnection'>TransactionalConnection</a>, moduleRef: ModuleRef, configService: ConfigService) => SettingsStoreService`}   />


### onModuleInit

<MemberInfo kind="method" type={`() => `}   />


### register

<MemberInfo kind="method" type={`(registration: <a href='/reference/typescript-api/settings-store/settings-store-registration#settingsstoreregistration'>SettingsStoreRegistration</a>) => void`}   />

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

<MemberInfo kind="method" type={`(ctx: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, 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

<MemberInfo kind="method" type={`(key: string, ctx: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>) => Promise<T | undefined>`}   />


### get

<MemberInfo kind="method" type={`(keyOrCtx: string | <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, ctxOrKey: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a> | string) => Promise<T | undefined>`}   />


### getMany

<MemberInfo kind="method" type={`(ctx: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, keys: string[]) => Promise<Record<string, <a href='/reference/typescript-api/common/json-compatible#jsoncompatible'>JsonCompatible</a><any>>>`}   />

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

<MemberInfo kind="method" type={`(keys: string[], ctx: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>) => Promise<Record<string, <a href='/reference/typescript-api/common/json-compatible#jsoncompatible'>JsonCompatible</a><any>>>`}   />


### getMany

<MemberInfo kind="method" type={`(keysOrCtx: string[] | <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, ctxOrKeys: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a> | string[]) => Promise<Record<string, <a href='/reference/typescript-api/common/json-compatible#jsoncompatible'>JsonCompatible</a><any>>>`}   />


### set

<MemberInfo kind="method" type={`(ctx: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, key: string, value: T) => Promise<<a href='/reference/typescript-api/settings-store/set-settings-store-value-result#setsettingsstorevalueresult'>SetSettingsStoreValueResult</a>>`}   />

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

<MemberInfo kind="method" type={`(key: string, value: T, ctx: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>) => Promise<<a href='/reference/typescript-api/settings-store/set-settings-store-value-result#setsettingsstorevalueresult'>SetSettingsStoreValueResult</a>>`}   />


### set

<MemberInfo kind="method" type={`(keyOrCtx: string | <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, keyOrValue: string | T, ctxOrValue: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a> | T) => Promise<<a href='/reference/typescript-api/settings-store/set-settings-store-value-result#setsettingsstorevalueresult'>SetSettingsStoreValueResult</a>>`}   />


### setMany

<MemberInfo kind="method" type={`(ctx: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, values: Record<string, <a href='/reference/typescript-api/common/json-compatible#jsoncompatible'>JsonCompatible</a><any>>) => Promise<<a href='/reference/typescript-api/settings-store/set-settings-store-value-result#setsettingsstorevalueresult'>SetSettingsStoreValueResult</a>[]>`}   />

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

<MemberInfo kind="method" type={`(values: Record<string, <a href='/reference/typescript-api/common/json-compatible#jsoncompatible'>JsonCompatible</a><any>>, ctx: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>) => Promise<<a href='/reference/typescript-api/settings-store/set-settings-store-value-result#setsettingsstorevalueresult'>SetSettingsStoreValueResult</a>[]>`}   />


### setMany

<MemberInfo kind="method" type={`(valuesOrCtx: Record<string, <a href='/reference/typescript-api/common/json-compatible#jsoncompatible'>JsonCompatible</a><any>> | <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, ctxOrValues: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a> | Record<string, <a href='/reference/typescript-api/common/json-compatible#jsoncompatible'>JsonCompatible</a><any>>) => Promise<<a href='/reference/typescript-api/settings-store/set-settings-store-value-result#setsettingsstorevalueresult'>SetSettingsStoreValueResult</a>[]>`}   />


### getFieldDefinition

<MemberInfo kind="method" type={`(key: string) => <a href='/reference/typescript-api/settings-store/settings-store-field-config#settingsstorefieldconfig'>SettingsStoreFieldConfig</a> | undefined`}   />

Get the field configuration for a key.
### validateValue

<MemberInfo kind="method" type={`(key: string, value: any, ctx: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>) => Promise<string | void>`}   />

Validate a value against its field definition.
### findOrphanedEntries

<MemberInfo kind="method" type={`(options: <a href='/reference/typescript-api/settings-store/cleanup-orphaned-settings-store-entries-options#cleanuporphanedsettingsstoreentriesoptions'>CleanupOrphanedSettingsStoreEntriesOptions</a> = {}) => Promise<<a href='/reference/typescript-api/settings-store/orphaned-settings-store-entry#orphanedsettingsstoreentry'>OrphanedSettingsStoreEntry</a>[]>`}   />

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

<MemberInfo kind="method" type={`(options: <a href='/reference/typescript-api/settings-store/cleanup-orphaned-settings-store-entries-options#cleanuporphanedsettingsstoreentriesoptions'>CleanupOrphanedSettingsStoreEntriesOptions</a> = {}) => Promise<<a href='/reference/typescript-api/settings-store/cleanup-orphaned-settings-store-entries-result#cleanuporphanedsettingsstoreentriesresult'>CleanupOrphanedSettingsStoreEntriesResult</a>>`}   />

Clean up orphaned settings store entries from the database.
### hasPermission

<MemberInfo kind="method" type={`(ctx: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, 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

<MemberInfo kind="method" type={`(ctx: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, key: string) => boolean`}  since="3.5.0"  />

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

<MemberInfo kind="method" type={`(ctx: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, key: string) => boolean`}  since="3.5.0"  />

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

<MemberInfo kind="method" type={`(key: string) => boolean`}   />

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


</div>
