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

    Type Alias Selectable<Q, S>

    Selectable: S extends NoTable
        ? KSelectable<Q>
        : Q extends Kysely<infer DB>
            ? S extends keyof DB ? KSelectable<DB[S]> : never
            : S extends keyof Q ? KSelectable<Q[S]> : never

    Converts a table of a Kysely database definition to the type of the data returned by SELECT queries.

    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 returned from SELECT * FROM wrd.entities:
    type WRDEntitiesSelect = Selectable<PlatformDB, "wrd.entities">;
    const mydb = db<PlatformDB>();
    type WRDEntitiesSelect2 = Selectable<typeof mydb, "wrd.entities">;
    type WRDEntitiesSelect3 = Selectable<PlatformDB["wrd.entities"]>;

    const rows: WRDEntitiesUpdate[] = await db<PlatformDB>().selectFrom("wrd.entities").selectAll().execute();