I have been following the docs on how to update a trip using Node.js,mongoose,express, as well as a couple of stack overflow questions here and here.
Inside of my Controller I originally had a save, which was working, but I needed to switch it to an update. When I run the code, nothing breaks and the place
is properly logged to the console as I would expect, which further indicates that the code is being run, but for some reason it isn't overwriting the item that has the same placeIdentifier.
What am I doing wrong that prevents this from updating?
My controller:
var place = {
identifier: placeIdentifier,
name: placeName,
location: Location,
travelStart: startDate,
travelEnd: endDate,
}
Place.findOneAndUpdate(
{identifier:placeIdentifier},
{ $set: place },
{upsert: true},
function() {
console.log(place)
console.log("place saved...")
}
);