Skip to content

Support idKey conversion in the storage driver, instead of requiring X.fromKey("id") #92

Description

@patroza

Current

export const PrimaryKey = flow(S.propertySignature, S.fromKey("id"))

isin: PrimaryKey(ISIN),

query(where("id", someIsin))

Desired

const PrimaryKeySymbol = Symbol.for("effect-app/PrimaryKey")
export const PrimaryKey = (key: string) => flow(S.annotate(PrimaryKeySymbol, key))

isin: PrimaryKey("isin")(ISIN)

query(where("isin", someIsin)) // this is already the result of not using `fromKey`

where the driver maps isin to id and back, if the underlying storage mechanism demands it, like CosmosDB.
aka probably don't convert for in memory/json, or in the future in any SQL driver - set the PrimaryKey in SQL.

Activity

  1. changed the title [-]Support idKey conversion in the storage driver, instead of requiring X.fromKey("id"[/-] [+]Support idKey conversion in the storage driver, instead of requiring X.fromKey("id")[/+] on Oct 26, 2024
  2. patroza commented on Oct 26, 2024

    @patroza
    MemberAuthor

    implementing but without the annotations, so keeping that as an upgrade in #91

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions