I am trying to add json to postgres.
I am sending json from postman
{
"Name":"name",
"address": [{
"address1": "address1",
"address2": "11",
"address3": "",
"city": "city",
"town": "",
"state": "",
"zipcode": "458770"
}]
}
Then using cast_embed to add to database
In my user schema
embeds_many :address, EmbedAddress, on_replace: :delete
Then
|> cast_embed(:address, with: &EmbedAddress.changeset/2)
And when inserting its adding list to field. Like
[{“address1”:“address1”,“address2”:null,“address3”:null,“city”:“city”,“country”:“country”,“desc”:null,“inserted_at”:“2019-11-17T21:31:52”,“party_id”:null,“state”:“hidd”,“town”:“hidd”,“type”:“P”,“updated_at”:“2019-11-17T21:31:52”,“zipcode”:“458770”}]
I want to add list with key like :
{“address”: [{“address1”:“address1”,“address2”:null,“address3”:null,“city”:“city”,“country”:“country”,“desc”:null,“inserted_at”:“2019-11-17T21:31:52”,“party_id”:null,“state”:“hidd”,“town”:“hidd”,“type”:“P”,“updated_at”:“2019-11-17T21:31:52”,“zipcode”:"458770”}]}
How can I keep address key in changeset or can add address key.
Thanks for help