I have the following JSON structure:
JSON = { "change_number": "CRQ91320s23",
"change_description": "Nexusg work",
"date": "2/10/2020",
"changeowner" : "Jeffre Hocking",
"implementer" : "john Elazi",
"PVT_testers": {
"Epic": {
"contact": "nathanbdas",
"email": "[email protected]" }}
I am using mongoDB + NodeJS to interface with it..
I want to add another entry beside "Epic" under "PVT_testers"..
This is my code, and when I run it, it replaces Epic with EPIC2 rather than adding to the same level.
Have cleaned the code to make it easier.
MongoClient.connect(url, function(err, db) {
var dbo = db.db("radar");
var myquery = { "change_number" : req.params.id };
var newvalues = { $set: {"PVT_testers" : {"EPIC2" : {"das2": "asd", "das2": "asd", "results": { "pre_outcome":"sucess" }}} }}
dbo.collection("changes").updateOne(myquery, newvalues, function(err, res) {
if (err) return res.json("Error:Database error" );
console.log(res)
db.close();
});