Simple question, but I can’t seem to find a simple answer.
Step 1: I pass this into the postgresql function as json
:
{
"name" : "John Doe",
"convert" : [32197,4234523,4235423]
}
Step 2: I would LIKE to store the id array within the database ids bigint[]
column as {32197,4234523,4235423}
How could I accomplish this?
2
Answers
The easiest way I found to do this was:
Where I am pulling the elements of the array out individually as text objects, then recasting to
BIGINT
's before pushing them back into anARRAY
Try using the function json_to_record.
Example of usage from the documentation:
In your case: