Skip to content

@lands.io/mod-sdk / IModStorage

Interface: IModStorage

Interface for mod persistent storage operations. This is the public API that mods use to interact with persistent storage.

Implemented by

Table of contents

Methods

Methods

delete

delete(scope, key, ownerId?): Promise\<boolean>

Delete an entry from persistent storage

Parameters

Name Type
scope string
key string
ownerId? string

Returns

Promise\<boolean>


filter

filter(scope, key, equals): Promise\<string[]>

Filter entries by matching value (returns owner IDs)

Parameters

Name Type
scope string
key string
equals unknown

Returns

Promise\<string[]>


get

get(scope, key, ownerId?): Promise\<unknown>

Retrieve a value from persistent storage

Parameters

Name Type
scope string
key string
ownerId? string

Returns

Promise\<unknown>


getOrderedAsc

getOrderedAsc(scope, key, limit?): Promise\<{ ownerId: string ; value: unknown }[]>

Get entries ordered by value in ascending order

Parameters

Name Type
scope string
key string
limit? number

Returns

Promise\<{ ownerId: string ; value: unknown }[]>


getOrderedDesc

getOrderedDesc(scope, key, limit?): Promise\<{ ownerId: string ; value: unknown }[]>

Get entries ordered by value in descending order

Parameters

Name Type
scope string
key string
limit? number

Returns

Promise\<{ ownerId: string ; value: unknown }[]>


getPlayer

getPlayer(playerId): Promise\<Record\<string, unknown>>

Get all data for a specific player

Parameters

Name Type
playerId string

Returns

Promise\<Record\<string, unknown>>


listKeys

listKeys(scope): Promise\<string[]>

List all keys in a scope

Parameters

Name Type
scope string

Returns

Promise\<string[]>


search(scope, key, substring): Promise\<{ ownerId: string ; value: unknown }[]>

Search for entries containing a substring (case-insensitive)

Parameters

Name Type
scope string
key string
substring string

Returns

Promise\<{ ownerId: string ; value: unknown }[]>


set

set(scope, key, value, ownerId?): Promise\<void>

Store a value in persistent storage (upsert operation)

Parameters

Name Type
scope string
key string
value unknown
ownerId? string

Returns

Promise\<void>


Source Code

View full implementation
export interface IModStorage {
  /**
   * Store a value in persistent storage (upsert operation)
   */
  set(scope: string, key: string, value: unknown, ownerId?: string): Promise<void>;

  /**
   * Retrieve a value from persistent storage
   */
  get(scope: string, key: string, ownerId?: string): Promise<unknown>;

  /**
   * Filter entries by matching value (returns owner IDs)
   */
  filter(scope: string, key: string, equals: unknown): Promise<string[]>;

  /**
   * Get entries ordered by value in descending order
   */
  getOrderedDesc(
    scope: string,
    key: string,
    limit?: number
  ): Promise<Array<{ ownerId: string; value: unknown }>>;

  /**
   * Get entries ordered by value in ascending order
   */
  getOrderedAsc(
    scope: string,
    key: string,
    limit?: number
  ): Promise<Array<{ ownerId: string; value: unknown }>>;

  /**
   * Search for entries containing a substring (case-insensitive)
   */
  search(
    scope: string,
    key: string,
    substring: string
  ): Promise<Array<{ ownerId: string; value: unknown }>>;

  /**
   * Delete an entry from persistent storage
   */
  delete(scope: string, key: string, ownerId?: string): Promise<boolean>;

  /**
   * List all keys in a scope
   */
  listKeys(scope: string): Promise<string[]>;

  /**
   * Get all data for a specific player
   */
  getPlayer(playerId: string): Promise<Record<string, unknown>>;
}