Populate document with other fields

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Populate document with other fields



I got the following document:


{
"_id": "5b5df332879b4769739e3ed0",
"name": "Back workout",
"exercises": [{
"_id": "5b5df9a7879b4769739e3ed1",
"results": [{"reps":"10","weight":"85"}, {"reps":"8","weight":"70"}]
}]
}



I want to populate the exercise based on the _id and also append the results data.


_id


results



Expected output:


{
"_id": "5b5df332879b4769739e3ed0",
"name": "Back workout",
"exercises": [{
"_id": "5b5df9a7879b4769739e3ed1",
"name": "EXERCISE_NAME",
"results": [{"reps":"10","weight":"85"}, {"reps":"8","weight":"70"}]
}]
}



My Schema looks like this:


const WorkoutSchema = new Schema({
_id: Schema.Types.ObjectId,
name: String,
exercises: [{
_id: { type: Schema.Types.ObjectId, ref: 'Exercise' },
results: Array,
}],
createdAt: Date,
updatedAt: Date,
});









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

WKFv,nLQZDhimCTDh
GM,9G5ea8,Mqpz lTb51kUJe MS0pnO 83dIkToCR6sJTjqveUniq6 dFLTR62zb,PPv91,KQuAp pY6ue0P3c

Popular posts from this blog

Makefile test if variable is not empty

Visual Studio Code: How to configure includePath for better IntelliSense results

Will Oldham