IF Commons GitHub

physical/layout

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0005-sql-store FR-008

The one module that knows the tables: every statement the store runs, by name, with the names of the tables and of the columns. The store (store.ts), the merge (merge.ts) and the dump (dump.ts) hold the rules of an operation and call these by name, and the migration (schema.ts) makes the tables and views these statements read: a different layout of the rows is a different module with the same names, and nothing else in the library changes with it. The rows are the version rows and the blobs; what a path holds is read from the views the migration makes, or from the rows of the path, and nothing is ever written to a view.

import { layoutOf } from "./layout.ts";
const l = layoutOf(sqlFor("sqlite", naming));
l.selectLastId().done(); // { text: "SELECT MAX(id) AS id FROM anyfs_versions", params: [] }

Source: commons/anyfs-sql/src/physical/layout.ts

0 of 2 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

Layouttypeno test imports it
type Layout = ReturnType<typeof layoutOf>;

The statements of the layout, by what each does. Each returns the builder of one statement.

layoutOffunctionno test imports it
function layoutOf(sql: { dialect: "duckdb" | "postgres" | "sqlite"; language: Dialect; query: () => Query; name: (text: … (2989 characters)
function layoutOf(sql: { dialect: "duckdb" | "postgres" | "sqlite"; language: Dialect; query: () => Query; name: (text: string) => string; table: (role: "blobs" | "cache" | "epochs" | "heads" | "meta" | "names" | "search" | "siblings" | "trust" | "vector" | "versions") => string; byteLength: string; type: (kind: "bytes" | "integer" | "path" | "text") => string; }): { lockWriters: () => Query | undefined; selectRowsOfPath: (path: string) => Query; selectLastId: () => Query; selectLastSeq: (replica: string) => Query; insertVersion: (v: Version) => Query; insertBlob: (sha: string, bytes: Uint8Array<ArrayBufferLike>) => Query; selectBlob: (sha: string) => Query; selectBlobsHeld: (shas: readonly string[]) => Query; selectRowsOfIds: (ids: readonly string[]) => Query; selectRowsOfSeq: (replica: string, seq: number) => Query; selectRowsSince: (since: Readonly<Record<string, number>>) => Query; selectVersionsPage: (after: { readonly id: string; readonly sum: string; } | undefined, limit: number) => Query; selectBlobsPage: (after: string | undefined, limit: number) => Query; countVersions: () => Query; countBlobs: () => Query; selectDangling: (limit: number) => Query; selectMissingBlobs: (limit: number) => Query; selectDuplicateIds: (limit: number) => Query; selectDuplicateSeqs: (limit: number) => Query; selectReplicasHeld: () => Query; selectCurrent: (path: string) => Query; selectCurrentStat: (path: string) => Query; selectPage: (prefix: string, after: string | undefined, limit: number) => Query; selectHistory: (path: string, limit: number) => Query; selectSiblings: (path: string) => Query; selectVector: () => Query; selectFact: (key: string) => Query; upsertFact: (key: string, value: string) => Query; selectTrust: () => Query; insertTrust: (replica: string) => Query; deleteTrust: (replica: string) => Query; insertPending: (key: string, text: string) => Query; selectPending: () => Query; deletePending: (key: string) => Query; countPending: () => Query; selectEpochs: () => Query; insertEpoch: (n: number, horizon: string, roster: string, retained: string, bound: string) => Query; selectCoveredHeads: (replica: string, upTo: number) => Query; selectCovered: (replica: string, upTo: number) => Query; selectSeqsAbove: (replica: string, floor: number) => Query; insertRetired: (replica: string, value: string) => Query; selectRetired: () => Query; deleteVersion: (id: string, sum: string) => Query; deleteBlobsUnnamed: () => Query; deleteWords: (path: string) => Query; deleteAllWords: () => Query; insertWords: (path: string, text: string) => Query; searchWords: (prefix: string, words: string, limit: number) => Query; selectIndexable: (maxBytes: number, after: string | undefined, limit: number) => Query; dumpVersions: () => Query; dumpBlobs: () => Query; replayVersion: (values: readonly (string | number | null)[]) => Query; replayBlob: (sha: string, bytes: Uint8Array<ArrayBufferLike>) => Query; selectVersionRows: () => Query; selectBlobRows: () => Query; }

The statements of the layout of the tables of a store, in the dialect of its statements.

Titles, headings, exports, tables, columns and requirements. Esc closes.