Im new to javascript and mongoDB, and i've been trying to get my database to work for a few days and finally figured out how to do it using push yesterday, so i apologize in advance if there are ways to do this much more efficiently.
Anyway i have the following schema:
var baseLinesSchema = new Schema ({
topName: { type: String, unique: true} ,
baseLines: [{
baseLineName: { type: String, unique: true},
baseLineStart: String ,
baseLineEnd: String,
targets: [{
target_Name: String,
targetStartedAt: String,
targetCurrentTime: String,
targetEndedAt: String,
targetStatus: Number
}],
}]
});
var allbaselines = mongoose.model('allbaselines', baseLinesSchema);
I can use baseLine.baseLines.push to insert a new baseline. What i want to do is insert a new target-subdocument into a specific baseLine (preferably using the baseline name) like
baseline.baseLines['baselineTwo'].push({targetName = "TargetOne"}, {targetStart = "2521212"});
What's the best way to do this?
Thanks!