In terms of performance and good practice, is it better to create a new row for every new json object or just append objects to an json object array all within one row? I'm building a NodeJS application that will let the user create, read, update and delete data from the json objects.
Also, how would you go about appending a new object or element to a specific json object array in the query in NodeJS and PostgresQL? I couldn't find any examples online. What is the insert command to do it for this example where the table name is "myData", "data" is the column name, and I want to insert 5 into "b":
data
{"a": 1, "b": [1, 2, 3]}
code:
var query = "INSERT INTO myData(data) as VALUES($1)";
// execute a query on our database
client.query(query, [5], function (err, result) {
if (err) throw err;
console.log(result);
});