© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
3 replies
Will

How to use a composite primary key in WHERE?

I have a table dv360UserProfilesTable which uses a composite key of userId and assignedUserProfileId. If I want to update this table, I'm struggling with how to use the composite key to batch update profiles. The below code throws the error: db error: ERROR: argument of WHERE must be type boolean, not type record

The docs also do not show an example of this https://orm.drizzle.team/docs/indexes-constraints#composite-primary-key

const updatedProfilesResponse = await db
    .update(dv360UserProfilesTable)
    .set({
      status: status,
      lastAuditedAt: new Date(),
      lastAuditedBy: session.user.id.toString(),
    })
    .where(
      or(
        profiles.map((profile: Profile) => {
          return and(
            eq(dv360UserProfilesTable.userId, profile.userId),
            eq(
              dv360UserProfilesTable.assignedUserRoleId,
              profile.assignedUserRoleId
            )
          );
        })
      )
    )
    .returning();
const updatedProfilesResponse = await db
    .update(dv360UserProfilesTable)
    .set({
      status: status,
      lastAuditedAt: new Date(),
      lastAuditedBy: session.user.id.toString(),
    })
    .where(
      or(
        profiles.map((profile: Profile) => {
          return and(
            eq(dv360UserProfilesTable.userId, profile.userId),
            eq(
              dv360UserProfilesTable.assignedUserRoleId,
              profile.assignedUserRoleId
            )
          );
        })
      )
    )
    .returning();
Indexes & Constraints – DrizzleORM
Drizzle ORM | %s
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Composite Primary Key?
Drizzle TeamDTDrizzle Team / help
16mo ago
Compostie primary key of a composite primary key
Drizzle TeamDTDrizzle Team / help
2y ago
How to reference to composite primary key
Drizzle TeamDTDrizzle Team / help
9mo ago
reference composite primary key
Drizzle TeamDTDrizzle Team / help
3y ago