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

Function SQLiteStoreLayer

packages/infra/src/Store/SQL.ts:717–746  ·  view source on GitHub ↗
(
  cfg: StorageConfig,
  options?: { makeSqlClientLayer?: (namespace: string) => Layer.Layer<SqlClient.SqlClient> }
)

Source from the content-addressed store, hash-verified

715 }))
716 },
717
718 queryRaw: (query) =>
719 s.all.pipe(
720 Effect.map(query.memory),
721 annotateDb({
722 operation: "queryRaw",
723 system: "sqlite",
724 collection: tableName,
725 entity: name
726 })
727 )
728 }
729
730 yield* seedNamespace("primary").pipe(Effect.orDie)
731
732 return s
733 })
734 }
735}
736
737export function SQLiteStoreLayer(
738 cfg: StorageConfig,
739 options?: { makeSqlClientLayer?: (namespace: string) => Layer.Layer<SqlClient.SqlClient> }
740) {
741 if (options?.makeSqlClientLayer) {
742 return Layer.effectContext(
743 Effect.gen(function*() {
744 const layerMap = yield* LayerMap.make(
745 (namespace: string) => options.makeSqlClientLayer!(namespace),
746 { idleTimeToLive: "10 minutes" }
747 )
748
749 const withNsSql: WithNsSqlFn = (ns, f) => SqlClient.SqlClient.use(f).pipe(Effect.provide(layerMap.get(ns)))

Callers 2

StoreMakerLayerFunction · 0.90
OrderRepoClass · 0.85

Calls 7

makeSQLiteStorePerNsFunction · 0.85
makeSQLStoreIntFunction · 0.85
makeMethod · 0.65
pipeMethod · 0.65
contextMethod · 0.65
addMethod · 0.65
toLayerMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…