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

    Type Alias Updateable<Q, S>

    Updateable: S extends NoTable
        ? KUpdateable<Q>
        : Q extends Kysely<infer DB>
            ? S extends keyof DB ? KUpdateable<DB[S]> : never
            : S extends keyof Q ? KUpdateable<Q[S]> : never

    Converts a Kysely database definition (or type of the Kysely client returned by db()) to the type of the data that can be updated in that table

    Type Parameters

    • Q

      Either

      • Database definition (eg PlatformDB)
      • Type of the Kysely instance (eq typeof db<PlatformDB>)
      • Table definition to convert (eq PlatformDB["WRD_Entities"])
    • S extends AllowedKeys<Q> = AllowedKeys<Q> & NoTable

      Table to select from a database definition or Kysely instance

    // The following three types all describe the data that can be updated in the wrd.entities table:
    type WRDEntitiesUpdate = Updateable<PlatformDB, "wrd.entities">;
    const mydb = db<PlatformDB>();
    type WRDEntitiesUpdate2 = Updateable<typeof mydb, "wrd.entities">;
    type WRDEntitiesUpdate3 = Updateable<PlatformDB["wrd.entities"]>;

    const updates: WRDEntitiesUpdate = { ... };
    const id: number = ...;
    await db<PlatformDB>().updateTable("wrd.entities").where("id", "=", id).set(updates).execute();