Answer the question
In order to leave comments, you need to log in
How to choose the right one, and then insert it into the database?
Good evening.
Here I understand with nodejs (3 years with php), and the question arose of how to correctly check the record and if there is no record in the database, then insert it (in a loop).
For example
var data=['word1','word2'];
data.forEach(function(key,val){
//....
});
Answer the question
In order to leave comments, you need to log in
In a forEach loop, you don't. forEach is synchronous and will not wait for the database query to complete.
Theoretically, you can do it with promises, generators and a for loop, or with recursion.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question