McPizza
McPizza
Explore posts from servers
DTDrizzle Team
Created by McPizza on 9/8/2023 in #help
Subqueries with INSERT - errors
I'm trying to create an insert that uses a subquery
const sq = db.select({id: orgs.id}).from(orgs).where(eq(orgs.publicId, input.orgPublicId)).as('sq');
const insertOrgResponse = await db.insert(orgInvitations).values({
orgId: sq.id,
invitedByUserId: userId,
publicId: newPublicId,
role: input.role,
inviteToken: nanoid(),
})
const sq = db.select({id: orgs.id}).from(orgs).where(eq(orgs.publicId, input.orgPublicId)).as('sq');
const insertOrgResponse = await db.insert(orgInvitations).values({
orgId: sq.id,
invitedByUserId: userId,
publicId: newPublicId,
role: input.role,
inviteToken: nanoid(),
})
Getting type errors on orgId, seems its not detecting correct type of sq.id If I explicitly set sq.id to a number, no more errors Still need to queries though....
4 replies
DTDrizzle Team
Created by McPizza on 9/7/2023 in #help
Relationships: Self one-one & one-many
No description
9 replies