I am trying to update the database value if it does not exist, and insert data if it does. I have attempted a method but unfortunately, it was not successful. Can anyone help me figure out how to achieve this efficiently?
fetchRecordFromFile.forEach(el => {
if(getDataFromDB.indexOf(el.city) > -1)
{
Post.create(el ,function(err,data_news){
if(err){
console.log(err)
}
else{
console.log("Inserted which are not before into database")
}
})
}
});