Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
patroza opened this issue Oct 26, 2024 · 1 comment · Fixed by #93
Closed

Comments

@patroza
Copy link
Member

patroza commented Oct 26, 2024

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.

@patroza patroza 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") Oct 26, 2024
@patroza
Copy link
Member Author

patroza commented Oct 26, 2024

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
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant