Interface WRDWritableType<S, T>
interface WRDWritableType<
S extends SchemaTypeDefinition,
T extends keyof S & string,
> {
legacySchema: boolean;
schema: WRDSchemaType<S>;
tag: T;
_getType(): Promise<HSVMObject>;
close(ids: number | number[], options?: EntityCloseOptions): Promise<void>;
createAttribute(
tag: string,
configuration: WRDAttributeCreateConfiguration,
): Promise<void>;
createEntity(
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>;
deleteAttribute(tag: string): Promise<void>;
describeAttribute(tag: string): Promise<WRDAttributeConfiguration | null>;
enrich<
EnrichKey extends string,
DataRow extends { [K in string]: number | null },
Mapping extends EnrichOutputMap<S[T]>,
RightOuterJoin extends boolean = false,
>(
data: DataRow[],
field: EnrichKey,
mapping: Mapping,
options?: {
allowMissing?: RightOuterJoin;
historyMode?: HistoryModeData | SimpleHistoryMode;
rightOuterJoin?: RightOuterJoin;
},
): WRDEnrichResult<S, T, EnrichKey, DataRow, Mapping, RightOuterJoin>;
exists(): Promise<boolean>;
find(
query: MatchObjectQueryable<S[T]>,
options?: { historyMode?: HistoryModeData | SimpleHistoryMode },
): Promise<number | null>;
getEventMasks(): Promise<string[]>;
getFormattedName(): string;
isReferenced(id: number): Promise<boolean>;
listAttributes(
parent?: string | number | null,
): Promise<WRDAttributeConfiguration[]>;
search<F extends string>(
field: F,
value: WhereValueOptions<S[T], F, WhereConditions<S[T], F> & "=">["value"],
options?: GetOptionsIfExists<
WhereValueOptions<S[T], F, WhereConditions<S[T], F> & "=">,
object,
> & { historyMode?: HistoryModeData | SimpleHistoryMode },
): Promise<number | null>;
updateAttribute(
tag: string,
configuration: Partial<WRDAttributeConfiguration>,
): Promise<void>;
updateEntity(
entity: number | MatchObjectQueryable<S[T]>,
value: WRDUpdatable<S[T]>,
options?: { importMode?: boolean },
): Promise<void>;
updateMetadata(
newmetadata: Partial<Omit<WRDTypeMetadata, "id" | "metaType">>,
): Promise<void>;
upsert<Q extends object, U extends object>(
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?: HistoryModeData | SimpleHistoryMode },
>,
): Promise<[number, boolean]>;
}
S extends SchemaTypeDefinition,
T extends keyof S & string,
> {
legacySchema: boolean;
schema: WRDSchemaType<S>;
tag: T;
_getType(): Promise<HSVMObject>;
close(ids: number | number[], options?: EntityCloseOptions): Promise<void>;
createAttribute(
tag: string,
configuration: WRDAttributeCreateConfiguration,
): Promise<void>;
createEntity(
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>;
deleteAttribute(tag: string): Promise<void>;
describeAttribute(tag: string): Promise<WRDAttributeConfiguration | null>;
enrich<
EnrichKey extends string,
DataRow extends { [K in string]: number | null },
Mapping extends EnrichOutputMap<S[T]>,
RightOuterJoin extends boolean = false,
>(
data: DataRow[],
field: EnrichKey,
mapping: Mapping,
options?: {
allowMissing?: RightOuterJoin;
historyMode?: HistoryModeData | SimpleHistoryMode;
rightOuterJoin?: RightOuterJoin;
},
): WRDEnrichResult<S, T, EnrichKey, DataRow, Mapping, RightOuterJoin>;
exists(): Promise<boolean>;
find(
query: MatchObjectQueryable<S[T]>,
options?: { historyMode?: HistoryModeData | SimpleHistoryMode },
): Promise<number | null>;
getEventMasks(): Promise<string[]>;
getFormattedName(): string;
isReferenced(id: number): Promise<boolean>;
listAttributes(
parent?: string | number | null,
): Promise<WRDAttributeConfiguration[]>;
search<F extends string>(
field: F,
value: WhereValueOptions<S[T], F, WhereConditions<S[T], F> & "=">["value"],
options?: GetOptionsIfExists<
WhereValueOptions<S[T], F, WhereConditions<S[T], F> & "=">,
object,
> & { historyMode?: HistoryModeData | SimpleHistoryMode },
): Promise<number | null>;
updateAttribute(
tag: string,
configuration: Partial<WRDAttributeConfiguration>,
): Promise<void>;
updateEntity(
entity: number | MatchObjectQueryable<S[T]>,
value: WRDUpdatable<S[T]>,
options?: { importMode?: boolean },
): Promise<void>;
updateMetadata(
newmetadata: Partial<Omit<WRDTypeMetadata, "id" | "metaType">>,
): Promise<void>;
upsert<Q extends object, U extends object>(
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?: HistoryModeData | SimpleHistoryMode },
>,
): Promise<[number, boolean]>;
}
Type Parameters
- S extends SchemaTypeDefinition
- T extends keyof S & string
Hierarchy
Methods
_ get Type
Returns Promise<HSVMObject>
close
Parameters
- ids: number | number[]
Optionaloptions: EntityCloseOptions
Returns Promise<void>
create Attribute
Parameters
- tag: string
- configuration: WRDAttributeCreateConfiguration
Returns Promise<void>
create Entity
- createEntity(
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>Parameters
- 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>
- value: Simplify<
delete Attribute
Parameters
- tag: string
Returns Promise<void>
describe Attribute
Parameters
- tag: string
Returns Promise<WRDAttributeConfiguration | null>
enrich
- enrich<
EnrichKey extends string,
DataRow extends { [K in string]: number | null },
Mapping extends EnrichOutputMap<S[T]>,
RightOuterJoin extends boolean = false,
>(
data: DataRow[],
field: EnrichKey,
mapping: Mapping,
options?: {
allowMissing?: RightOuterJoin;
historyMode?: HistoryModeData | SimpleHistoryMode;
rightOuterJoin?: RightOuterJoin;
},
): WRDEnrichResult<S, T, EnrichKey, DataRow, Mapping, RightOuterJoin>Type Parameters
Parameters
- data: DataRow[]
- field: EnrichKey
- mapping: Mapping
- options: {
allowMissing?: RightOuterJoin;
historyMode?: HistoryModeData | SimpleHistoryMode;
rightOuterJoin?: RightOuterJoin;
} = {}OptionalallowMissing?: RightOuterJoinKeep original data records even if no match was found
OptionalhistoryMode?: HistoryModeData | SimpleHistoryModeHistory mode for matching enriching records
OptionalrightOuterJoin?: RightOuterJoin
Returns WRDEnrichResult<S, T, EnrichKey, DataRow, Mapping, RightOuterJoin>
exists
Test whether this type actually exists in the database
Returns Promise<boolean>
find
- find(
query: MatchObjectQueryable<S[T]>,
options?: { historyMode?: HistoryModeData | SimpleHistoryMode },
): Promise<number | null>Returns the wrdId of the entity that matches the properties of the query object.
Parameters
- query: MatchObjectQueryable<S[T]>
Query object (field-value pairs)
Optionaloptions: { historyMode?: HistoryModeData | SimpleHistoryMode }Options for the search
Returns Promise<number | null>
- query: MatchObjectQueryable<S[T]>
get Event Masks
Returns Promise<string[]>
get Formatted Name
Get the name to us in error messages
Returns string
is Referenced
Parameters
- id: number
Returns Promise<boolean>
list Attributes
Parameters
Optionalparent: string | number | null
Returns Promise<WRDAttributeConfiguration[]>
search
- search<F extends string>(
field: F,
value: WhereValueOptions<S[T], F, WhereConditions<S[T], F> & "=">["value"],
options?: GetOptionsIfExists<
WhereValueOptions<S[T], F, WhereConditions<S[T], F> & "=">,
object,
> & { historyMode?: HistoryModeData | SimpleHistoryMode },
): Promise<number | null>Type Parameters
- F extends string
Parameters
Returns Promise<number | null>
update Attribute
Parameters
- tag: string
- configuration: Partial<WRDAttributeConfiguration>
Returns Promise<void>
update Entity
- updateEntity(
entity: number | MatchObjectQueryable<S[T]>,
value: WRDUpdatable<S[T]>,
options?: { importMode?: boolean },
): Promise<void>Parameters
- entity: number | MatchObjectQueryable<S[T]>
- value: WRDUpdatable<S[T]>
Optionaloptions: { importMode?: boolean }
Returns Promise<void>
update Metadata
Parameters
- newmetadata: Partial<Omit<WRDTypeMetadata, "id" | "metaType">>
Returns Promise<void>
upsert
- upsert<Q extends object, U extends object>(
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?: HistoryModeData | SimpleHistoryMode },
>,
): Promise<[number, boolean]>Type Parameters
- Q extends object
- U extends object
Parameters
- 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?: HistoryModeData | SimpleHistoryMode },
>
Returns Promise<[number, boolean]>
A WRD type obtained from a WRDWritableSchema, which allows its metadata and attributes to be modified