Class WRDSchema<S>
Type Parameters
- S extends SchemaTypeDefinition = AnySchemaType
Hierarchy (View Summary)
- WRDSchemaType<S>
- WRDSchema
Index
Constructors
Properties
Methods
Constructors
constructor
Type Parameters
- S extends SchemaTypeDefinition = AnySchemaType
Parameters
- tag: string
Returns WRDSchema<S>
Methods
__ clear Cache
Returns void
__ ensure Schema Data
Parameters
- __namedParameters: { refresh?: boolean } = {}
Returns Promise<SchemaData>
__ get Type Tag
Parameters
- type: number
Returns Promise<string | null>
__ to WRD Type Id
Parameters
- tag: string | undefined
Returns Promise<number>
[get WRD Schema Type]
Parameters
- type: string
- allowMissingType: true
Returns Promise<HSVMObject | null>
Parameters
- type: string
- allowMissingType: false
Returns Promise<HSVMObject>
close
create Type
delete
describe Type
Describe a wrdType
Parameters
- tagOrId: string | number
Either the string tag or the type number to describe
Returns Promise<WRDTypeMetadata | null>
- tagOrId: string | number
enrich
- enrich<
T extends string,
EnrichKey extends string,
DataRow extends { [K in string]: number | null },
Mapping extends EnrichOutputMap<S[T]>,
RightOuterJoin extends boolean = false,
>(
type: T,
data: DataRow[],
field: EnrichKey,
mapping: Mapping,
options?: {
allowMissing?: RightOuterJoin;
historyMode?: SimpleHistoryMode | HistoryModeData;
rightOuterJoin?: RightOuterJoin;
},
): WRDEnrichResult<S, T, EnrichKey, DataRow, Mapping, RightOuterJoin>Type Parameters
Parameters
- type: T
- data: DataRow[]
- field: EnrichKey
- mapping: Mapping
- options: {
allowMissing?: RightOuterJoin;
historyMode?: SimpleHistoryMode | HistoryModeData;
rightOuterJoin?: RightOuterJoin;
} = {}OptionalallowMissing?: RightOuterJoinKeep original data records even if no match was found
OptionalhistoryMode?: SimpleHistoryMode | HistoryModeDataHistory mode for matching enriching records
OptionalrightOuterJoin?: RightOuterJoin
Returns WRDEnrichResult<S, T, EnrichKey, DataRow, Mapping, RightOuterJoin>
exists
Test whether this schema actually exists in the database
Returns Promise<boolean>
extend With
find
- find<T extends string>(
type: T,
query: MatchObjectQueryable<S[T]>,
options?: { historyMode?: SimpleHistoryMode | HistoryModeData },
): Promise<number | null>Returns the wrdId of the entity that matches the properties of the query object.
Type Parameters
- T extends string
Parameters
Returns Promise<number | null>
get Event Masks
get Fields
get Id
Parameters
- opts: { allowMissing: true }
Returns Promise<number | null>
Parameters
Optionalopts: { allowMissing?: boolean }
Returns Promise<number>
get Next Guid
get Next Id
get Type
has Type
Test whether a type exists in this schema
Parameters
- tag: string
Returns Promise<boolean>
insert
- insert<T extends string>(
type: T,
value: Partial<WRDInsertable<S[T]>>,
options: { importMode?: boolean; temp: true },
): Promise<number>Type Parameters
- T extends string
Parameters
- type: T
- value: Partial<WRDInsertable<S[T]>>
- options: { importMode?: boolean; temp: true }
Returns Promise<number>
- insert<T extends string>(
type: T,
value: Partial<WRDInsertable<S[T]>>,
options: { importMode: true; temp?: boolean },
): Promise<number>Type Parameters
- T extends string
Parameters
- type: T
- value: Partial<WRDInsertable<S[T]>>
- options: { importMode: true; temp?: boolean }
Returns Promise<number>
- insert<T extends string>(
type: T,
value: Simplify<
{
[K in string
| number
| symbol as ToWRDAttr<S[T][K]>["__insertable"] extends true
? false extends ToWRDAttr<S[T][K]>["__required"] ? K : never
: never]?: GetInputType<S[T][K]>
} & {
[K in string
| number
| symbol as InsertableAndRequired<ToWRDAttr<S[T][K]>> extends true
? K
: never]: GetInputType<S[T][K]>
},
>,
options?: { importMode?: boolean; temp?: boolean },
): Promise<number>Type Parameters
- T extends string
Parameters
- type: T
- value: Simplify<
{
[K in string
| number
| symbol as ToWRDAttr<S[T][K]>["__insertable"] extends true
? false extends ToWRDAttr<S[T][K]>["__required"] ? K : never
: never]?: GetInputType<S[T][K]>
} & {
[K in string
| number
| symbol as InsertableAndRequired<ToWRDAttr<S[T][K]>> extends true
? K
: never]: GetInputType<S[T][K]>
},
> Optionaloptions: { importMode?: boolean; temp?: boolean }
Returns Promise<number>
list Types
modify
query
search
- search<T extends string, F extends string>(
type: T,
field: F,
value: WhereValueOptions<S[T], F, WhereConditions<S[T], F> & "=">["value"],
options?: GetOptionsIfExists<
WhereValueOptions<S[T], F, WhereConditions<S[T], F> & "=">,
object,
> & { historyMode?: SimpleHistoryMode | HistoryModeData },
): Promise<number | null>Returns the wrdId of an entity that has a field with a specific value, or null if not found.
Type Parameters
- T extends string
- F extends string
Parameters
- type: T
- field: F
Field to filter on
- value: WhereValueOptions<S[T], F, WhereConditions<S[T], F> & "=">["value"]
Value to match (using condition "=")
Optionaloptions: GetOptionsIfExists<
WhereValueOptions<S[T], F, WhereConditions<S[T], F> & "=">,
object,
> & { historyMode?: SimpleHistoryMode | HistoryModeData }Additional options for the filter
Returns Promise<number | null>
select From
update
- update<T extends string>(
type: T,
entity: number | MatchObjectQueryable<S[T]>,
value: WRDUpdatable<S[T]>,
options?: { importMode?: boolean },
): Promise<void>Updates fields of a specific entity
Type Parameters
- T extends string
Parameters
- type: T
- entity: number | MatchObjectQueryable<S[T]>
wrdId of the entity to update, or a query object to find the entity (throws if none or multiple entities match the query)
- value: WRDUpdatable<S[T]>
Value to match (using condition "=")
Optionaloptions: { importMode?: boolean }Additional options for the filter
Returns Promise<void>
update Schema
Parameters
- updates: SchemaUpdates
Returns Promise<void>
upsert
- upsert<T extends string, Q extends object, U extends object>(
type: T,
query: Q & Pick<WRDUpdatable<S[T]>, keyof S[T] & keyof WRDUpdatable<S[T]>> & MatchObjectQueryable<
S[T],
> & Record<
Exclude<keyof Q, keyof S[T] | keyof S[T] & keyof WRDUpdatable<S[T]>>,
never,
>,
value: U & WRDUpdatable<S[T]> & Record<
Exclude<keyof U, keyof WRDUpdatable<S[T]>>,
never,
>,
...options: UpsertOptions<
Omit<
Simplify<
{
[K in string
| number
| symbol as ToWRDAttr<S[T][K]>["__insertable"] extends true
? false extends ToWRDAttr<(...)[(...)][K]>["__required"]
? K
: never
: never]?: GetInputType<S[T][K]>
} & {
[K in string
| number
| symbol as InsertableAndRequired<ToWRDAttr<S[T][K]>> extends true
? K
: never]: GetInputType<S[T][K]>
},
>,
RequiredKeys<Q>
| RequiredKeys<U>,
>,
{ historyMode?: SimpleHistoryMode | HistoryModeData },
>,
): Promise<[number, boolean]>Insert an entity, or update if it exists
Type Parameters
- T extends string
- Q extends object
- U extends object
Parameters
- type: T
- query: Q & Pick<WRDUpdatable<S[T]>, keyof S[T] & keyof WRDUpdatable<S[T]>> & MatchObjectQueryable<
S[T],
> & Record<
Exclude<keyof Q, keyof S[T] | keyof S[T] & keyof WRDUpdatable<S[T]>>,
never,
> - value: U & WRDUpdatable<S[T]> & Record<
Exclude<keyof U, keyof WRDUpdatable<S[T]>>,
never,
> - ...options: UpsertOptions<
Omit<
Simplify<
{
[K in string
| number
| symbol as ToWRDAttr<S[T][K]>["__insertable"] extends true
? false extends ToWRDAttr<(...)[(...)][K]>["__required"] ? K : never
: never]?: GetInputType<S[T][K]>
} & {
[K in string
| number
| symbol as InsertableAndRequired<ToWRDAttr<S[T][K]>> extends true
? K
: never]: GetInputType<S[T][K]>
},
>,
RequiredKeys<Q>
| RequiredKeys<U>,
>,
{ historyMode?: SimpleHistoryMode | HistoryModeData },
>
Returns Promise<[number, boolean]>
Open a WRD schema by tag