KeyValueStore overview
Added in v1.0.0
Table of contents
combinators
prefix
Signature
export declare const prefix: {
(prefix: string): <S extends KeyValueStore.AnyStore>(self: S) => S
<S extends KeyValueStore.AnyStore>(self: S, prefix: string): S
}
Added in v1.0.0
constructors
make
Signature
export declare const make: (
impl: Omit<KeyValueStore, typeof TypeId | "has" | "modify" | "isEmpty" | "forSchema"> & Partial<KeyValueStore>
) => KeyValueStore
Added in v1.0.0
layers
layerFileSystem
Signature
export declare const layerFileSystem: (
directory: string
) => Layer.Layer<KeyValueStore, PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>
Added in v1.0.0
layerMemory
Signature
export declare const layerMemory: Layer.Layer<KeyValueStore>
Added in v1.0.0
layerSchema
Signature
export declare const layerSchema: <A, I, R>(
schema: Schema.Schema<A, I, R>,
tagIdentifier: string
) => {
readonly tag: Context.Tag<SchemaStore<R, A>, SchemaStore<R, A>>
readonly layer: Layer.Layer<SchemaStore<R, A>, never, KeyValueStore>
}
Added in v1.0.0
models
KeyValueStore (interface)
Signature
export interface KeyValueStore {
readonly [TypeId]: TypeId
/**
* Returns the value of the specified key if it exists.
*/
readonly get: (key: string) => Effect.Effect<Option.Option<string>, PlatformError.PlatformError>
/**
* Sets the value of the specified key.
*/
readonly set: (key: string, value: string) => Effect.Effect<void, PlatformError.PlatformError>
/**
* Removes the specified key.
*/
readonly remove: (key: string) => Effect.Effect<void, PlatformError.PlatformError>
/**
* Removes all entries.
*/
readonly clear: Effect.Effect<void, PlatformError.PlatformError>
/**
* Returns the number of entries.
*/
readonly size: Effect.Effect<number, PlatformError.PlatformError>
/**
* Updates the value of the specified key if it exists.
*/
readonly modify: (
key: string,
f: (value: string) => string
) => Effect.Effect<Option.Option<string>, PlatformError.PlatformError>
/**
* Returns true if the KeyValueStore contains the specified key.
*/
readonly has: (key: string) => Effect.Effect<boolean, PlatformError.PlatformError>
/**
* Checks if the KeyValueStore contains any entries.
*/
readonly isEmpty: Effect.Effect<boolean, PlatformError.PlatformError>
/**
* Create a SchemaStore for the specified schema.
*/
readonly forSchema: <A, I, R>(schema: Schema.Schema<A, I, R>) => SchemaStore<R, A>
}
Added in v1.0.0
SchemaStore (interface)
Signature
export interface SchemaStore<R, A> {
readonly [SchemaStoreTypeId]: SchemaStoreTypeId
/**
* Returns the value of the specified key if it exists.
*/
readonly get: (
key: string
) => Effect.Effect<Option.Option<A>, PlatformError.PlatformError | ParseResult.ParseError, R>
/**
* Sets the value of the specified key.
*/
readonly set: (key: string, value: A) => Effect.Effect<void, PlatformError.PlatformError | ParseResult.ParseError, R>
/**
* Removes the specified key.
*/
readonly remove: (key: string) => Effect.Effect<void, PlatformError.PlatformError>
/**
* Removes all entries.
*/
readonly clear: Effect.Effect<void, PlatformError.PlatformError>
/**
* Returns the number of entries.
*/
readonly size: Effect.Effect<number, PlatformError.PlatformError>
/**
* Updates the value of the specified key if it exists.
*/
readonly modify: (
key: string,
f: (value: A) => A
) => Effect.Effect<Option.Option<A>, PlatformError.PlatformError | ParseResult.ParseError, R>
/**
* Returns true if the KeyValueStore contains the specified key.
*/
readonly has: (key: string) => Effect.Effect<boolean, PlatformError.PlatformError>
/**
* Checks if the KeyValueStore contains any entries.
*/
readonly isEmpty: Effect.Effect<boolean, PlatformError.PlatformError>
}
Added in v1.0.0
tags
KeyValueStore
Signature
export declare const KeyValueStore: Context.Tag<KeyValueStore, KeyValueStore>
Added in v1.0.0
type id
SchemaStoreTypeId
Signature
export declare const SchemaStoreTypeId: typeof SchemaStoreTypeId
Added in v1.0.0
SchemaStoreTypeId (type alias)
Signature
export type SchemaStoreTypeId = typeof SchemaStoreTypeId
Added in v1.0.0
TypeId
Signature
export declare const TypeId: typeof TypeId
Added in v1.0.0
TypeId (type alias)
Signature
export type TypeId = typeof TypeId
Added in v1.0.0
utils
KeyValueStore (namespace)
Added in v1.0.0
AnyStore (type alias)
Signature
export type AnyStore = KeyValueStore | SchemaStore<any, any>
Added in v1.0.0