WRDWritableType | WebHare Platform SDK
WebHare Platform SDK
    Preparing search index...

    Interface WRDWritableType<S, T>

    A WRD type obtained from a WRDWritableSchema, which allows its metadata and attributes to be modified

    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]>;
    }

    Type Parameters

    • S extends SchemaTypeDefinition
    • T extends keyof S & string

    Hierarchy

    • WRDType<S, T>
      • WRDWritableType
    Index

    Properties

    legacySchema: boolean
    schema: WRDSchemaType<S>
    tag: T

    Methods

    • Returns Promise<HSVMObject>

    • Parameters

      • ids: number | number[]
      • Optionaloptions: EntityCloseOptions

      Returns Promise<void>

    • Parameters

      • tag: string
      • configuration: WRDAttributeCreateConfiguration

      Returns Promise<void>

    • 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>

    • Parameters

      • tag: string

      Returns Promise<void>

    • Parameters

      • tag: string

      Returns Promise<WRDAttributeConfiguration | null>

    • Type Parameters

      • EnrichKey extends string
      • DataRow extends { [K in string]: number | null }
      • Mapping extends EnrichOutputMap<S[T]>
      • RightOuterJoin extends boolean = false

      Parameters

      • data: DataRow[]
      • field: EnrichKey
      • mapping: Mapping
      • options: {
            allowMissing?: RightOuterJoin;
            historyMode?: HistoryModeData | SimpleHistoryMode;
            rightOuterJoin?: RightOuterJoin;
        } = {}
        • OptionalallowMissing?: RightOuterJoin

          Keep original data records even if no match was found

        • OptionalhistoryMode?: HistoryModeData | SimpleHistoryMode

          History mode for matching enriching records

        • OptionalrightOuterJoin?: RightOuterJoin

          With the modern wrd() API you should switch to allowMissing: true

      Returns WRDEnrichResult<S, T, EnrichKey, DataRow, Mapping, RightOuterJoin>

    • Test whether this type actually exists in the database

      Returns Promise<boolean>

    • 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>

    • Returns Promise<string[]>

    • Get the name to us in error messages

      Returns string

    • Parameters

      • id: number

      Returns Promise<boolean>

    • Parameters

      • Optionalparent: string | number | null

      Returns Promise<WRDAttributeConfiguration[]>

    • Type Parameters

      • F extends string

      Parameters

      • field: F
      • value: WhereValueOptions<S[T], F, WhereConditions<S[T], F> & "=">["value"]
      • Optionaloptions: GetOptionsIfExists<
            WhereValueOptions<S[T], F, WhereConditions<S[T], F> & "=">,
            object,
        > & { historyMode?: HistoryModeData | SimpleHistoryMode }

      Returns Promise<number | null>

    • Parameters

      • tag: string
      • configuration: Partial<WRDAttributeConfiguration>

      Returns Promise<void>

    • Parameters

      • entity: number | MatchObjectQueryable<S[T]>
      • value: WRDUpdatable<S[T]>
      • Optionaloptions: { importMode?: boolean }

      Returns Promise<void>

    • Parameters

      • newmetadata: Partial<Omit<WRDTypeMetadata, "id" | "metaType">>

      Returns Promise<void>

    • 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]>