MCPcopy Create free account
hub / github.com/effect-app/libs / parseSelectRow

Function parseSelectRow

packages/infra/src/Store/SQL.ts:45–65  ·  view source on GitHub ↗
(
  row: Record<string, unknown>,
  idKey: PropertyKey
)

Source from the content-addressed store, hash-verified

43{}
44
45/** @internal */
46export const parseRow = <Encoded extends FieldValues>(
47 row: { id: string; _etag: string | null; data: string },
48 idKey: PropertyKey,
49 defaultValues: Partial<Encoded>
50): PersistenceModelType<Encoded> => {
51 const data = (typeof row.data === "string" ? JSON.parse(row.data) : row.data) as object
52 return { ...defaultValues, ...data, [idKey]: row.id, _etag: row._etag ?? undefined } as PersistenceModelType<Encoded>
53}
54
55const parseSelectRow = (
56 row: Record<string, unknown>,
57 idKey: PropertyKey
58): any => {
59 const result: Record<string, unknown> = {}
60 for (const [key, value] of Object.entries(row)) {
61 if (key === "id") {
62 result[idKey as string] = value
63 result["id"] = value
64 } else if (typeof value === "string") {
65 try {
66 result[key] = JSON.parse(value)
67 } catch {
68 result[key] = value

Callers 2

makeSQLStoreIntFunction · 0.70
makeSQLiteStorePerNsFunction · 0.70

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…