@launchdarkly/js-server-sdk-common - v2.26.1
    Preparing search index...

    Interface LDTransactionalFeatureStore

    Transactional version of LDFeatureStore with support for applyChanges

    interface LDTransactionalFeatureStore {
        all(
            kind: DataKind,
            callback: (res: LDFeatureStoreKindData) => void,
        ): void;
        applyChanges(
            basis: boolean,
            data: LDFeatureStoreDataStorage,
            callback: () => void,
            initMetadata?: InitMetadata,
            selector?: string,
        ): void;
        close(): void;
        delete(
            kind: DataKind,
            key: string,
            version: number,
            callback: () => void,
        ): void;
        get(
            kind: DataKind,
            key: string,
            callback: (res: LDFeatureStoreItem | null) => void,
        ): void;
        getDescription?(): string;
        getInitMetaData?(): InitMetadata | undefined;
        getSelector?(): string | undefined;
        init(
            allData: LDFeatureStoreDataStorage,
            callback: (err?: Error) => void,
            initMetadata?: InitMetadata,
        ): void;
        initialized(callback: (isInitialized: boolean) => void): void;
        isStoreAvailable?(callback: (isAvailable: boolean) => void): void;
        upsert(
            kind: DataKind,
            data: LDKeyedFeatureStoreItem,
            callback: (err?: Error) => void,
        ): void;
    }

    Hierarchy (View Summary)

    Implemented by

    Index
    • Applies the provided data onto the existing data, replacing all data or upserting depending on the basis parameter. Must call applyChanges providing basis before calling applyChanges that is not a basis.

      Parameters

      • basis: boolean

        If true, completely overwrites the current contents of the data store with the provided data. If false, upserts the items in the provided data. Upserts are made only if provided items have newer versions than existing items.

      • data: LDFeatureStoreDataStorage

        An object in which each key is the "namespace" of a collection (e.g. "features") and the value is an object that maps keys to entities. The actual type of this parameter is interfaces.FullDataSet<VersionedData>.

      • callback: () => void

        Will be called after the changes are applied.

      • OptionalinitMetadata: InitMetadata

        Optional metadata to initialize the feature store with.

      • Optionalselector: string

        opaque string that uniquely identifies the state that contains the changes

      Returns void

    • Delete an entity from the store.

      Deletion should be implemented by storing a placeholder object with the property deleted: true and a version property equal to the provided version. In other words, it should be exactly the same as calling upsert with such an object.

      Parameters

      • kind: DataKind

        The type of data to be accessed. The actual type of this parameter is interfaces.DataKind.

      • key: string

        The unique key of the entity within the specified collection.

      • version: number

        A number that must be greater than the version property of the existing entity in order for it to be deleted. If it is less than or equal to the existing version, the method should do nothing.

      • callback: () => void

        Will be called when the delete operation is complete.

      Returns void

    • Initialize the store, overwriting any existing data.

      Parameters

      • allData: LDFeatureStoreDataStorage

        An object in which each key is the "namespace" of a collection (e.g. "features") and the value is an object that maps keys to entities. The actual type of this parameter is interfaces.FullDataSet<VersionedData>.

      • callback: (err?: Error) => void

        Will be called when the store has been initialized. If the store could not apply the data, then it may be called with an error. Implementations are not required to report errors.

      • OptionalinitMetadata: InitMetadata

        Optional metadata to initialize the feature store with.

      Returns void

    • Tests whether the store is initialized.

      "Initialized" means that the store has been populated with data, either by the client having called init() within this process, or by another process (if this is a shared database).

      Parameters

      • callback: (isInitialized: boolean) => void

        Will be called back with the boolean result.

      Returns void

    • Check if the underlying storage can be accessed.

      The check must be inexpensive, for example a read of a single key. It must not write any data. The SDK can call this method at a fixed interval while the store is in an error state.

      Parameters

      • callback: (isAvailable: boolean) => void

        Will be called with true when the storage responds to the check, or with false when it does not.

      Returns void