-
|
Currently I am doing this to pass an array of jsonb: test('jsonb array', async () => {
await db.query(`drop table if exists jsonb_array_test`)
await db.query(`create table jsonb_array_test(id int, jsons jsonb[])`)
const values = [{n: 'one'}, {n: 'two'}, {n: 'three'}]
const result = await db.query(
`
insert into jsonb_array_test
values (1, $1::jsonb[])
returning *
`,
[values.map(v => JSON.stringify(v))],
)
expect(result).toEqual([{id: 1, jsons: values}])
})Is there a better way to do this though? I am worried that pg-promise is creating a pointless array of type Note: in the context I don't want to use |
Beta Was this translation helpful? Give feedback.
Answered by
vitaly-t
May 8, 2025
Replies: 1 comment 1 reply
-
|
Can you clarify what you expect the resulting query to look like? |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
mmkal
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you clarify what you expect the resulting query to look like?