Drizzle query with where clause and primary composite key

Hello, I have defined a composite key and am now trying to run a drizzle query to lookup the event where that key exists. I have defined the following query, is this the fastest way to go about doing this lookup? Thanks!

Drizzle Schema Table:
export const scans = pgTable(
    "scans",
    {
        createdAt: timestamp("created_at").notNull().defaultNow(),
        userID: varchar("user_id", { length: 255 }).notNull(),
        eventID: integer("event_id").notNull(),
        count: integer("count").notNull(),
    },
    (table) => ({
        id: primaryKey({ columns: [table.userID, table.eventID] }),
    })
);


Lookup:

const scan = await db.query.scans.findFirst({
  where: and(eq(scans.eventID, eventID), eq(scans.userID, userID)),
});


Thanks for the help!
Was this page helpful?