How to push to json array

I have a json array column and I'm trying to append on array with array_cat, but I get the error
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[]`)
})


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


How to solve the error? thanks
Was this page helpful?