I have an array of json Objects in following format:
[
{
product: {
id: 24,
raisedby: 'abc@testcom'
}
},
{
product: {
id: 12,
raisedby: 'xyz@testcom'
}
},
{
product: {
id: 9,
raisedby: 'abcde@testcom'
}
}
]
I am trying to build a Postgres Insert Statement as follows but it does not work. Any help appreciated
insert into public.redeem_request(redeem_product_id, redeem_raisedby)
select (e->> 'product'->> 'id')::int,
e->>'product' ->> 'raisedby'
from jsonb_array_elements($1) as t(e)
returning *
e ->> 'product'
needs to bee -> 'product'