This is a gist created for a comment to an answer provided on stackoverflow.com.
@David Weldon: Thanks for your answer. Below I edited my input, but got the below output. Maybe this is the default behavior of db.ideas.find()
. I'll do some looking around. I expected to also get the subdocuments also when I performed the db.ideas.find()
.
Code I ran:
Ideas.update("bKXXrpYmppFBfq9Kx", {
$addToSet: {
score: { userId: "W9YEs84QFhZzJeB6j", score: 1 },
votedOnBy: "W9YEs84QFhZzJeB6j"
},
$inc: {
overallScore: 1,
timesVotedOn: 1
}
});
Output from mongo db console:
meteor:PRIMARY> db.ideas.find()
{
"_id" : "bKXXrpYmppFBfq9Kx",
"title" : "Jump through the portal",
"body" : "The elves from Eldernland should jump through the blue portal mentioned in episode one.",
"userId" : "W9YEs84QFhZzJeB6j",
"author" : "Nate Beck",
"episodeId" : "LbDynnAHxAgM5PPXM",
"timestamp" : ISODate("2016-06-07T20:37:05.775Z"),
"votedOnBy" : [
"W9YEs84QFhZzJeB6j"
],
"timesVotedOn" : 3,
"score" : [
{
}
],
"overallScore" : 1
}
I was expecting to see what was in "Score" this looks like an empty object.