© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago
Astatine

How to push to json array

I have a json array column and I'm trying to append on array with
array_cat
array_cat
, but I get the error
function array_cat(json[], record) does not exist
function array_cat(json[], record) does not exist


My schema is
const table1 = pgTable("table1", {
  messages: json("messages")
    .array()
    .$type<Message[]>()
    .notNull()
    .default(sql`ARRAY[]::json[]`)
})
const table1 = pgTable("table1", {
  messages: json("messages")
    .array()
    .$type<Message[]>()
    .notNull()
    .default(sql`ARRAY[]::json[]`)
})


and the update query is
await ctx.db
  .update(table1)
  .set({
    messages: sql`array_cat(${table1.messages}, ${newMessages})`,
  })
await ctx.db
  .update(table1)
  .set({
    messages: sql`array_cat(${table1.messages}, ${newMessages})`,
  })


How to solve the error? 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

json_arrayagg(json_array ...
Drizzle TeamDTDrizzle Team / help
2y ago
How to push to an array?
Drizzle TeamDTDrizzle Team / help
3y ago
How to filter null values from json_arrayagg
Drizzle TeamDTDrizzle Team / help
3y ago
Postgrest inserting json array results in stringified array
Drizzle TeamDTDrizzle Team / help
2y ago