Hi there folks,
I have this code:
newproject
.findOneAndUpdate({ projectname: item }, {responsetime: [{timestamp: secondsSinceEpoch, pingtime: res.ping_time}]})
.then(function() {
console.log("Should have updated with timestamp and ping time!");
});
But the problem is that this overwrites responsetime and pingtime in the database. Any way I can make a new object instead of overwriting?
My schema looks like this:
var schema2 = new mongoose.Schema({
email: "string",
name: "string",
projectname: "string",
dashID: "string",
pingStatus: "string",
responsetime: [{timestamp: String, pingtime: String}],
glitch: "boolean"
})
But I don’t want to have to add a new object to the schema. I want this to be done automatically. (Should be [{timestamp: String, pingtime: String}, {timestamp: String, pingtime: String}]
etc.) Any ideas on how to do this? Can you put me in the right direction (e.g. specific parts of docs about this)
Thanks,
Eddie