© 2026 Hedgehog Software, LLC

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

Querying PG table by JSONB field

hi! I can't find any reference on how to query a Postgress table by a JSONB field. Eg: I have a table
export const authMethods = pgTable(
  'auth_methods',
  {
    tenantId: varchar('tenant_id', { length: 128 }).notNull(),

    userId: varchar('user_id', { length: 128 })
      .notNull()
      .references(() => users.id),

    type: authMethodTypeEnum('type').notNull(),

    identifier: text('identifier').notNull(),
    secret: text('secret').notNull(),

    authVendorData: jsonb('auth_vendor_data'),

    createdAt: timestamp('created_at').defaultNow(),
    updatedAt: timestamp('updated_at').defaultNow(),
  }
)
export const authMethods = pgTable(
  'auth_methods',
  {
    tenantId: varchar('tenant_id', { length: 128 }).notNull(),

    userId: varchar('user_id', { length: 128 })
      .notNull()
      .references(() => users.id),

    type: authMethodTypeEnum('type').notNull(),

    identifier: text('identifier').notNull(),
    secret: text('secret').notNull(),

    authVendorData: jsonb('auth_vendor_data'),

    createdAt: timestamp('created_at').defaultNow(),
    updatedAt: timestamp('updated_at').defaultNow(),
  }
)

authVendorData
authVendorData
sometimes has an
email
email
field. I want to check if any
authMethod
authMethod
exists that has an
authVendorData.email
authVendorData.email
with a specific value. How can I do that with drizzle? If this currently requires me to drop down to
sql
sql
, it would be very helpful to know that as well. Thanks!
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

Generated columns / JSONB-ish querying
Drizzle TeamDTDrizzle Team / help
11mo ago
jsonb field definition.
Drizzle TeamDTDrizzle Team / help
3y ago
Querying table based on a field of a related table
Drizzle TeamDTDrizzle Team / help
3y ago
JSONB field and zod validation
Drizzle TeamDTDrizzle Team / help
3mo ago