Join the Stack Overflow Community
Stack Overflow is a community of 6.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

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);


  });
share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.