I'm trying to update a document which has a specific ID with the current date/time but the below code is not resulting in the DB getting updated and no errors. Any help would be great, thanks.
Schema:
var MerchantShema = new Schema({ merchant_id: Number, merchant_aw_id: Number, merchant_name: String, merchant_url: String, merchant_image: String, product_feed: String, product_feed_updated: Date, created_at: {type: Date, default: Date.now}, updated_at: {type: Date, default: Date.now} }); Update Query:
updateMerchantLastProductUpdate: function (mID) { now = new Date(); var query = { "merchant_aw_id" : mID }; Merchants.update(query, { "product_feed_updated": now }, function (err) { if (err) return console.error(err); }) } Route
app.get('/queries', function (req, res) { queries.updateMerchantLastProductUpdate("2926"); }); Example document
{ "_id": { "$oid": "55997638e4b01f0391cb99aa" }, "merchant_id": "0003", "merchant_aw_id": "2926", "merchant_name": "Multipower", "merchant_url": "www.multipower.com/uk/", "merchant_image": "", "product_feed": "aw", "product_feed_updated": "", "created_at": "", "updated_at": "" }