issue with update from select

doing this:
await db
.update(stores)
.set({
discordBotId: db
.select({
id: discordBots.id,
})
.from(discordBots)
.leftJoin(stores, eq(stores.discordBotId, discordBots.id))
.groupBy(discordBots.id)
.orderBy(asc(sql`COUNT(${stores.id})`))
.limit(1),
})
.where(eq(stores.id, store.id));
await db
.update(stores)
.set({
discordBotId: db
.select({
id: discordBots.id,
})
.from(discordBots)
.leftJoin(stores, eq(stores.discordBotId, discordBots.id))
.groupBy(discordBots.id)
.orderBy(asc(sql`COUNT(${stores.id})`))
.limit(1),
})
.where(eq(stores.id, store.id));
causes this:
Type 'Omit<PgSelectBase<"discord_bots", { id: PgColumn<{ name: "id"; tableName: "discord_bots"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: true; enumValues: undefined; baseColumn: never; }, {}, {}>; }, ... 5 more ..., { ...; }>, "groupBy" | ... 1 more ... | "lim...' is not assignable to type 'string | SQL<unknown> | null | undefined'.
Type 'Omit<PgSelectBase<"discord_bots", { id: PgColumn<{ name: "id"; tableName: "discord_bots"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: true; enumValues: undefined; baseColumn: never; }, {}, {}>; }, ... 5 more ..., { ...; }>, "groupBy" | ... 1 more ... | "lim...' is missing the following properties from type 'SQL<unknown>': queryChunks, shouldInlineParams, append, toQuery, and 5 more.ts(2322)
Type 'Omit<PgSelectBase<"discord_bots", { id: PgColumn<{ name: "id"; tableName: "discord_bots"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: true; enumValues: undefined; baseColumn: never; }, {}, {}>; }, ... 5 more ..., { ...; }>, "groupBy" | ... 1 more ... | "lim...' is not assignable to type 'string | SQL<unknown> | null | undefined'.
Type 'Omit<PgSelectBase<"discord_bots", { id: PgColumn<{ name: "id"; tableName: "discord_bots"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: true; enumValues: undefined; baseColumn: never; }, {}, {}>; }, ... 5 more ..., { ...; }>, "groupBy" | ... 1 more ... | "lim...' is missing the following properties from type 'SQL<unknown>': queryChunks, shouldInlineParams, append, toQuery, and 5 more.ts(2322)
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server