I'm writing a function that pass in a string called "term" to search in my MongoDB, then add its results to an existed empty array of results called "result[]":
var searchAndAddToResults = (result, term)=> {
  Place.find({ $or: [
    {name: term}, {category: term}
  ] }, places=> {
    for (let i in places) {
      if (!itemExists(result, places[i].toObject())) {
        result.push(places[i].toObject())
      }
    }
    console.log(result)   // result isn't empty, which is good
  })
  console.log(result)   // result is empty, which is bad and weird
  return result    // this returned result is also empty, THIS is the real problem
}
Can anyone help me with restructuring this code to get it work? Thanks