Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 48 additions & 3 deletions src/datatype/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { validate } from '@comapeo/schema'
import { getTableConfig } from 'drizzle-orm/sqlite-core'
import { eq, inArray, sql } from 'drizzle-orm'
import { eq, inArray, sql, Columns } from 'drizzle-orm'

Check failure on line 3 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.x)

'"drizzle-orm"' has no exported member named 'Columns'. Did you mean 'Column'?

Check failure on line 3 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (windows-latest, 20.x)

'"drizzle-orm"' has no exported member named 'Columns'. Did you mean 'Column'?

Check failure on line 3 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (macos-latest, 20.x)

'"drizzle-orm"' has no exported member named 'Columns'. Did you mean 'Column'?

Check failure on line 3 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (macos-latest, 18.x)

'"drizzle-orm"' has no exported member named 'Columns'. Did you mean 'Column'?

Check failure on line 3 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (windows-latest, 18.x)

'"drizzle-orm"' has no exported member named 'Columns'. Did you mean 'Column'?
import { randomBytes } from 'node:crypto'
import { noop, mutatingDeNullify } from '../utils.js'
import { NotFoundError } from '../errors.js'
Expand Down Expand Up @@ -114,6 +114,8 @@
db,
getTranslations,
getDeviceIdForVersionId,
// Which properties can be hydrated e.g. `observationTable.presetRef -> presetTable`
hydratedRefs = [],

Check failure on line 118 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.x)

Property 'hydratedRefs' does not exist on type '{ table: TTable; dataStore: TDataStore; db: BetterSQLite3Database<Record<string, never>>; getTranslations?: ((value: { docRefType: "UNRECOGNIZED" | "observation" | "track" | "preset" | "field" | "projectSettings" | "deviceInfo" | "role" | "type_unspecified"; languageCode: string; propertyRef?: string | undefined; regionCode?: string | undefined; } & { docRef: { docId: string; versionId?: string | undefined; }; }) => Promise<{ schemaName: "translation"; docRef: { docId: string; versionId: string; }; docRefType: "UNRECOGNIZED" | "observation" | "track" | "preset" | "field" | "projectSettings" | "deviceInfo" | "role" | "type_unspecified"; propertyRef: string; languageCode: string; regionCode?: string | undefined; message: string; docId: string; versionId: string; originalVersionId: string; createdAt: string; updatedAt: string; links: string[]; deleted: boolean; }[]>) | undefined; getDeviceIdForVersionId: (versionId: string) => Promise<string>; }'.

Check failure on line 118 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (windows-latest, 20.x)

Property 'hydratedRefs' does not exist on type '{ table: TTable; dataStore: TDataStore; db: BetterSQLite3Database<Record<string, never>>; getTranslations?: ((value: { docRefType: "UNRECOGNIZED" | "observation" | "track" | "preset" | "field" | "projectSettings" | "deviceInfo" | "role" | "type_unspecified"; languageCode: string; propertyRef?: string | undefined; regionCode?: string | undefined; } & { docRef: { docId: string; versionId?: string | undefined; }; }) => Promise<{ schemaName: "translation"; docRef: { docId: string; versionId: string; }; docRefType: "UNRECOGNIZED" | "observation" | "track" | "preset" | "field" | "projectSettings" | "deviceInfo" | "role" | "type_unspecified"; propertyRef: string; languageCode: string; regionCode?: string | undefined; message: string; docId: string; versionId: string; originalVersionId: string; createdAt: string; updatedAt: string; links: string[]; deleted: boolean; }[]>) | undefined; getDeviceIdForVersionId: (versionId: string) => Promise<string>; }'.

Check failure on line 118 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (macos-latest, 20.x)

Property 'hydratedRefs' does not exist on type '{ table: TTable; dataStore: TDataStore; db: BetterSQLite3Database<Record<string, never>>; getTranslations?: ((value: { docRefType: "UNRECOGNIZED" | "observation" | "track" | "preset" | "field" | "projectSettings" | "deviceInfo" | "role" | "type_unspecified"; languageCode: string; propertyRef?: string | undefined; regionCode?: string | undefined; } & { docRef: { docId: string; versionId?: string | undefined; }; }) => Promise<{ schemaName: "translation"; docRef: { docId: string; versionId: string; }; docRefType: "UNRECOGNIZED" | "observation" | "track" | "preset" | "field" | "projectSettings" | "deviceInfo" | "role" | "type_unspecified"; propertyRef: string; languageCode: string; regionCode?: string | undefined; message: string; docId: string; versionId: string; originalVersionId: string; createdAt: string; updatedAt: string; links: string[]; deleted: boolean; }[]>) | undefined; getDeviceIdForVersionId: (versionId: string) => Promise<string>; }'.

Check failure on line 118 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (macos-latest, 18.x)

Property 'hydratedRefs' does not exist on type '{ table: TTable; dataStore: TDataStore; db: BetterSQLite3Database<Record<string, never>>; getTranslations?: ((value: { docRefType: "UNRECOGNIZED" | "observation" | "track" | "preset" | "field" | "projectSettings" | "deviceInfo" | "role" | "type_unspecified"; languageCode: string; propertyRef?: string | undefined; regionCode?: string | undefined; } & { docRef: { docId: string; versionId?: string | undefined; }; }) => Promise<{ schemaName: "translation"; docRef: { docId: string; versionId: string; }; docRefType: "UNRECOGNIZED" | "observation" | "track" | "preset" | "field" | "projectSettings" | "deviceInfo" | "role" | "type_unspecified"; propertyRef: string; languageCode: string; regionCode?: string | undefined; message: string; docId: string; versionId: string; originalVersionId: string; createdAt: string; updatedAt: string; links: string[]; deleted: boolean; }[]>) | undefined; getDeviceIdForVersionId: (versionId: string) => Promise<string>; }'.

Check failure on line 118 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (windows-latest, 18.x)

Property 'hydratedRefs' does not exist on type '{ table: TTable; dataStore: TDataStore; db: BetterSQLite3Database<Record<string, never>>; getTranslations?: ((value: { docRefType: "UNRECOGNIZED" | "observation" | "track" | "preset" | "field" | "projectSettings" | "deviceInfo" | "role" | "type_unspecified"; languageCode: string; propertyRef?: string | undefined; regionCode?: string | undefined; } & { docRef: { docId: string; versionId?: string | undefined; }; }) => Promise<{ schemaName: "translation"; docRef: { docId: string; versionId: string; }; docRefType: "UNRECOGNIZED" | "observation" | "track" | "preset" | "field" | "projectSettings" | "deviceInfo" | "role" | "type_unspecified"; propertyRef: string; languageCode: string; regionCode?: string | undefined; message: string; docId: string; versionId: string; originalVersionId: string; createdAt: string; updatedAt: string; links: string[]; deleted: boolean; }[]>) | undefined; getDeviceIdForVersionId: (versionId: string) => Promise<string>; }'.
}) {
super()
this.#dataStore = dataStore
Expand All @@ -135,6 +137,44 @@
.prepare(),
getManyWithDeleted: db.select().from(table).prepare(),
}
if (hydratedRefs.length) {
// select all fields
// we will add more
const toSelect = { ...this.#table[Columns] }

Check failure on line 143 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.x)

Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'MapeoDocTables'.

Check failure on line 143 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (windows-latest, 20.x)

Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'MapeoDocTables'.

Check failure on line 143 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (macos-latest, 20.x)

Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'MapeoDocTables'.

Check failure on line 143 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (macos-latest, 18.x)

Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'MapeoDocTables'.

Check failure on line 143 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (windows-latest, 18.x)

Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'MapeoDocTables'.
for (const { field, table } of hydratedRefs) {
const { name } = field
if (!name.endsWith('Ref')) {
throw new Error('Only fields that end with `Ref` can be hydrated')
}
// Strip out Ref
const propertyName = name.slice(0, -3)
toSelect[propertyName] = table
}

let getManyHydrated = db
.select(toSelect)
.from(table)
.where(eq(table.deleted, false))

let getByDocIdHydrated = db
.select()
.from(table)
.where(eq(table.docId, sql.placeholder('docId')))

for (const { field, table } of hydratedRefs) {
getManyHydrated = getManyHydrated.fulljoin(

Check failure on line 165 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.x)

Property 'fulljoin' does not exist on type 'Omit<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, any, "single" | "partial", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", ({ [x: string]: any; } | SelectPartialResult<any, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>)[], any>, "where">'. Did you mean 'fullJoin'?

Check failure on line 165 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (windows-latest, 20.x)

Property 'fulljoin' does not exist on type 'Omit<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, any, "single" | "partial", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", ({ [x: string]: any; } | SelectPartialResult<any, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>)[], any>, "where">'. Did you mean 'fullJoin'?

Check failure on line 165 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (macos-latest, 20.x)

Property 'fulljoin' does not exist on type 'Omit<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, any, "single" | "partial", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", ({ [x: string]: any; } | SelectPartialResult<any, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>)[], any>, "where">'. Did you mean 'fullJoin'?

Check failure on line 165 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (macos-latest, 18.x)

Property 'fulljoin' does not exist on type 'Omit<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, any, "single" | "partial", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", ({ [x: string]: any; } | SelectPartialResult<any, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>)[], any>, "where">'. Did you mean 'fullJoin'?

Check failure on line 165 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (windows-latest, 18.x)

Property 'fulljoin' does not exist on type 'Omit<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, any, "single" | "partial", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", ({ [x: string]: any; } | SelectPartialResult<any, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>)[], any>, "where">'. Did you mean 'fullJoin'?
table,
eq(field, table.docId)
)
getByDocIdHydrated = getByDocIdHydrated.fulljoin(

Check failure on line 169 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.x)

Property 'fulljoin' does not exist on type 'Omit<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>, "where">'. Did you mean 'fullJoin'?

Check failure on line 169 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (windows-latest, 20.x)

Property 'fulljoin' does not exist on type 'Omit<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>, "where">'. Did you mean 'fullJoin'?

Check failure on line 169 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (macos-latest, 20.x)

Property 'fulljoin' does not exist on type 'Omit<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>, "where">'. Did you mean 'fullJoin'?

Check failure on line 169 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (macos-latest, 18.x)

Property 'fulljoin' does not exist on type 'Omit<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>, "where">'. Did you mean 'fullJoin'?

Check failure on line 169 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (windows-latest, 18.x)

Property 'fulljoin' does not exist on type 'Omit<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>, "where">'. Did you mean 'fullJoin'?
table,
eq(field, table.docId)
)
}

this.#sql.getManyHydrated = getManyHydrated.prepare()

Check failure on line 175 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.x)

Property 'getManyHydrated' does not exist on type '{ getByDocId: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getMany: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getManyWithDeleted: SQLiteSelectPrepare<SQLiteSelectBase<GetSelectTableName<TTable>, "sync", RunResult, GetSelectTableSelection<TTable>, "single", GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, false, never, { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>>>; }'.

Check failure on line 175 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (windows-latest, 20.x)

Property 'getManyHydrated' does not exist on type '{ getByDocId: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getMany: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getManyWithDeleted: SQLiteSelectPrepare<SQLiteSelectBase<GetSelectTableName<TTable>, "sync", RunResult, GetSelectTableSelection<TTable>, "single", GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, false, never, { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>>>; }'.

Check failure on line 175 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (macos-latest, 20.x)

Property 'getManyHydrated' does not exist on type '{ getByDocId: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getMany: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getManyWithDeleted: SQLiteSelectPrepare<SQLiteSelectBase<GetSelectTableName<TTable>, "sync", RunResult, GetSelectTableSelection<TTable>, "single", GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, false, never, { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>>>; }'.

Check failure on line 175 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (macos-latest, 18.x)

Property 'getManyHydrated' does not exist on type '{ getByDocId: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getMany: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getManyWithDeleted: SQLiteSelectPrepare<SQLiteSelectBase<GetSelectTableName<TTable>, "sync", RunResult, GetSelectTableSelection<TTable>, "single", GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, false, never, { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>>>; }'.

Check failure on line 175 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (windows-latest, 18.x)

Property 'getManyHydrated' does not exist on type '{ getByDocId: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getMany: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getManyWithDeleted: SQLiteSelectPrepare<SQLiteSelectBase<GetSelectTableName<TTable>, "sync", RunResult, GetSelectTableSelection<TTable>, "single", GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, false, never, { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>>>; }'.
this.#sql.getByDocIdHydrated = getByDocIdHydrated.prepare()

Check failure on line 176 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.x)

Property 'getByDocIdHydrated' does not exist on type '{ getByDocId: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getMany: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getManyWithDeleted: SQLiteSelectPrepare<SQLiteSelectBase<GetSelectTableName<TTable>, "sync", RunResult, GetSelectTableSelection<TTable>, "single", GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, false, never, { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>>>; }'.

Check failure on line 176 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (windows-latest, 20.x)

Property 'getByDocIdHydrated' does not exist on type '{ getByDocId: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getMany: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getManyWithDeleted: SQLiteSelectPrepare<SQLiteSelectBase<GetSelectTableName<TTable>, "sync", RunResult, GetSelectTableSelection<TTable>, "single", GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, false, never, { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>>>; }'.

Check failure on line 176 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (macos-latest, 20.x)

Property 'getByDocIdHydrated' does not exist on type '{ getByDocId: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getMany: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getManyWithDeleted: SQLiteSelectPrepare<SQLiteSelectBase<GetSelectTableName<TTable>, "sync", RunResult, GetSelectTableSelection<TTable>, "single", GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, false, never, { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>>>; }'.

Check failure on line 176 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (macos-latest, 18.x)

Property 'getByDocIdHydrated' does not exist on type '{ getByDocId: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getMany: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getManyWithDeleted: SQLiteSelectPrepare<SQLiteSelectBase<GetSelectTableName<TTable>, "sync", RunResult, GetSelectTableSelection<TTable>, "single", GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, false, never, { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>>>; }'.

Check failure on line 176 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (windows-latest, 18.x)

Property 'getByDocIdHydrated' does not exist on type '{ getByDocId: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getMany: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getManyWithDeleted: SQLiteSelectPrepare<SQLiteSelectBase<GetSelectTableName<TTable>, "sync", RunResult, GetSelectTableSelection<TTable>, "single", GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, false, never, { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>>>; }'.
}
this.on('newListener', (eventName) => {
if (eventName !== 'updated-docs') return
if (this.listenerCount('updated-docs') > 1) return
Expand Down Expand Up @@ -228,9 +268,14 @@
* @param {string} [options.lang]
* @returns {Promise<null | (TDoc & DerivedDocFields)>}
*/
async getByDocId(docId, { mustBeFound = true, lang } = {}) {
async getByDocId(docId, { mustBeFound = true, lang, hydrate = false } = {}) {

Check failure on line 271 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.x)

Property 'hydrate' does not exist on type '{ mustBeFound?: boolean | undefined; lang?: string | undefined; }'.

Check failure on line 271 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (windows-latest, 20.x)

Property 'hydrate' does not exist on type '{ mustBeFound?: boolean | undefined; lang?: string | undefined; }'.

Check failure on line 271 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (macos-latest, 20.x)

Property 'hydrate' does not exist on type '{ mustBeFound?: boolean | undefined; lang?: string | undefined; }'.

Check failure on line 271 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (macos-latest, 18.x)

Property 'hydrate' does not exist on type '{ mustBeFound?: boolean | undefined; lang?: string | undefined; }'.

Check failure on line 271 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (windows-latest, 18.x)

Property 'hydrate' does not exist on type '{ mustBeFound?: boolean | undefined; lang?: string | undefined; }'.
await this.#dataStore.indexer.idle()
const result = this.#sql.getByDocId.get({ docId })
let result = null
if (hydrate) {
result = this.#sql.getByDocIdHydrated.get({ docId })

Check failure on line 275 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.x)

Property 'getByDocIdHydrated' does not exist on type '{ getByDocId: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getMany: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getManyWithDeleted: SQLiteSelectPrepare<SQLiteSelectBase<GetSelectTableName<TTable>, "sync", RunResult, GetSelectTableSelection<TTable>, "single", GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, false, never, { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>>>; }'.

Check failure on line 275 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (windows-latest, 20.x)

Property 'getByDocIdHydrated' does not exist on type '{ getByDocId: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getMany: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getManyWithDeleted: SQLiteSelectPrepare<SQLiteSelectBase<GetSelectTableName<TTable>, "sync", RunResult, GetSelectTableSelection<TTable>, "single", GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, false, never, { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>>>; }'.

Check failure on line 275 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (macos-latest, 20.x)

Property 'getByDocIdHydrated' does not exist on type '{ getByDocId: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getMany: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getManyWithDeleted: SQLiteSelectPrepare<SQLiteSelectBase<GetSelectTableName<TTable>, "sync", RunResult, GetSelectTableSelection<TTable>, "single", GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, false, never, { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>>>; }'.

Check failure on line 275 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (macos-latest, 18.x)

Property 'getByDocIdHydrated' does not exist on type '{ getByDocId: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getMany: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getManyWithDeleted: SQLiteSelectPrepare<SQLiteSelectBase<GetSelectTableName<TTable>, "sync", RunResult, GetSelectTableSelection<TTable>, "single", GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, false, never, { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>>>; }'.

Check failure on line 275 in src/datatype/index.js

View workflow job for this annotation

GitHub Actions / build (windows-latest, 18.x)

Property 'getByDocIdHydrated' does not exist on type '{ getByDocId: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getMany: SQLiteSelectPrepare<SQLiteSelectBase<(string | undefined) & GetSelectTableName<TTable>, "sync", RunResult, Assume<GetSelectTableSelection<TTable>, ColumnsSelection>, "single", Assume<GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, Record<string, JoinNullability>>, false, "where", { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], Assume<BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>, ColumnsSelection>>>; getManyWithDeleted: SQLiteSelectPrepare<SQLiteSelectBase<GetSelectTableName<TTable>, "sync", RunResult, GetSelectTableSelection<TTable>, "single", GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}, false, never, { [K in keyof { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }]: { [Key in keyof GetSelectTableSelection<TTable> & string]: SelectResultField<GetSelectTableSelection<TTable>[Key], true>; }[K]; }[], BuildSubquerySelection<GetSelectTableSelection<TTable>, GetSelectTableName<TTable> extends string ? Record<string & GetSelectTableName<TTable>, "not-null"> : {}>>>; }'.
} else {
result = this.#sql.getByDocId.get({ docId })
}
if (result) {
return this.#mutatingAddDerivedFields(result, { lang })
} else if (mustBeFound) {
Expand Down
11 changes: 11 additions & 0 deletions test/data-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import RAM from 'random-access-memory'
import crypto from 'hypercore-crypto'
import {
observationTable,
presetTable,
trackTable,
translationTable,
} from '../src/schema/project.js'
Expand Down Expand Up @@ -353,6 +354,8 @@ test('translation', async () => {
)
})

test.only('Hydration pulls data from other tables', async () => {})

/**
* @param {object} [opts={}]
* @param {Buffer} [opts.projectKey]
Expand Down Expand Up @@ -425,9 +428,17 @@ async function testenv(opts = {}) {

const translationApi = new TranslationApi({ dataType: translationDataType })

const hydratedRefs = [
{
field: observationTable.presetRef,
table: presetTable,
},
]

const dataType = new DataType({
dataStore,
table: observationTable,
hydratedRefs,
db,
getTranslations: translationApi.get.bind(translationApi),
async getDeviceIdForVersionId() {
Expand Down
Loading