© 2026 Hedgehog Software, LLC

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

update a nested jsonb field

I have a table with a jsonb column that is something like this:
{
  foo: {
     bar: 'test'
     baz: 'hi'
  },
  foo2: {
    bar: 'test2'
    baz: 'hi2'
  }
}
{
  foo: {
     bar: 'test'
     baz: 'hi'
  },
  foo2: {
    bar: 'test2'
    baz: 'hi2'
  }
}


I want to update
columnName.foo.bar
columnName.foo.bar
and not mutate anything else, how would I do this?

In SQL, would be something like:

UPDATE table
SET
    columnName = jsonb_set(columnName, '{foo,bar}', to_jsonb('changing test to something else'), false)
WHERE id = 'someId';
UPDATE table
SET
    columnName = jsonb_set(columnName, '{foo,bar}', to_jsonb('changing test to something else'), false)
WHERE id = 'someId';


Looked around on GitHub issues, Discord, and the docs and can't find a way to do this the Drizzle way.
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

jsonb field definition.
Drizzle TeamDTDrizzle Team / help
3y ago
JSONB field and zod validation
Drizzle TeamDTDrizzle Team / help
3mo ago
error while trying to update jsonb via jsonb_set
Drizzle TeamDTDrizzle Team / help
2y ago
Best way to query jsonb field
Drizzle TeamDTDrizzle Team / help
3y ago