MCPcopy Create free account
hub / github.com/tinyplex/tinybase / createTabularPersister

Function createTabularPersister

src/persisters/common/database/tabular.ts:31–234  ·  view source on GitHub ↗
(
  store: PersistedStore<Persist>,
  executeCommand: DatabaseExecuteCommand,
  addPersisterListener: (
    listener: PersisterListener<Persist>,
  ) => ListeningHandle | Promise<ListeningHandle>,
  delPersisterListener: (
    listeningHandle: ListeningHandle,
  ) => void | Promise<void>,
  onIgnoredError: ((error: any) => void) | undefined,
  extraDestroy: () => void,
  persist: Persist,
  [
    tablesLoadConfig,
    tablesSaveConfig,
    [
      valuesLoad,
      valuesSave,
      valuesTableName,
      valuesLoadValueIds,
      valuesSaveValueIds,
    ],
  ]: DefaultedTabularConfig,
  managedTableNames: string[],
  querySchema: QuerySchema,
  thing: any,
  getThing: string,
  columnType: string,
  upsert?: Upsert,
  encode?: (cellOrValue: any) => string | number,
  decode?: (field: string | number) => any,
)

Source from the content-addressed store, hash-verified

29import type {DefaultedTabularConfig} from './config.ts';
30
31export const createTabularPersister = <
32 ListeningHandle,
33 Persist extends Persists = Persists.StoreOnly,
34>(
35 store: PersistedStore<Persist>,
36 executeCommand: DatabaseExecuteCommand,
37 addPersisterListener: (
38 listener: PersisterListener<Persist>,
39 ) => ListeningHandle | Promise<ListeningHandle>,
40 delPersisterListener: (
41 listeningHandle: ListeningHandle,
42 ) => void | Promise<void>,
43 onIgnoredError: ((error: any) => void) | undefined,
44 extraDestroy: () => void,
45 persist: Persist,
46 [
47 tablesLoadConfig,
48 tablesSaveConfig,
49 [
50 valuesLoad,
51 valuesSave,
52 valuesTableName,
53 valuesLoadValueIds,
54 valuesSaveValueIds,
55 ],
56 ]: DefaultedTabularConfig,
57 managedTableNames: string[],
58 querySchema: QuerySchema,
59 thing: any,
60 getThing: string,
61 columnType: string,
62 upsert?: Upsert,
63 encode?: (cellOrValue: any) => string | number,
64 decode?: (field: string | number) => any,
65): Persister<Persist> => {
66 const [refreshSchema, loadTable, saveTable, transaction] =
67 getCommandFunctions(
68 executeCommand,
69 managedTableNames,
70 querySchema,
71 onIgnoredError,
72 columnType,
73 upsert,
74 encode,
75 decode,
76 );
77
78 const saveTables = (
79 tables:
80 | Tables
81 | {
82 [tableId: Id]:
83 | {[rowId: Id]: {[cellId: Id]: CellOrUndefined} | undefined}
84 | undefined;
85 },
86 partial?: boolean,
87 ) =>
88 promiseAll(

Callers

nothing calls this directly

Calls 2

getCommandFunctionsFunction · 0.90
createCustomPersisterFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…