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[]`)
})
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
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server