Good day. There is a certain array.

[ {car: mazda, type: kabriolet, color: red, rider: whore}; {car: BMW, type: sedan, color: black, rider: big boss}; ] 

Using this array to populate the database, I encounter difficulty. The difficulty is as follows. The table needs properties such as car and rider . But all the properties that return the server. Hence the error, carview table was created only with car and rider columns.

The SQL query looks like this:

  var query = connection.query('insert into carview set ?', aboutcar[i], function(err, result) { if (err) { console.error(err); return; } console.error(result); }); 

It turns out only if I delete the properties of objects that I do not want with the help of the operator delete . But I read on the Habré that such a method causes a leak, and the code becomes healthy because of these delete . I think the answer lies in the use of the INSERT operator. Help guide the true path.

  • If "you read something", attach a link to where you read: most likely this is an old and long-fixed bug, and you are in vain afraid. And think about why sending extra data to the database if it can be cut off in advance. - D-side
  • [ habrahabr.ru/post/150723/] solution as it does not work. The fact of the matter is that the extra data I do not need. For this and cut them delete'om. - Gareev Denis
  • It turns out, if I have 20 deleteals, is there nothing wrong with that? - Gareev Denis
  • And you think theoretically, what could be better than other options. - D-side
  • Hm Is that only if the operator INSERT supports the selection of the desired properties. The code will be shorter. - Gareev Denis

0