Hi, I am working on a practice code and came across this piece of code and don’t understand some parts of it. Can someone please help me?
I get that it is defining a variable with the value of this.commentIds but what does || [ ] do?
Also it returns the search results of a collection called Comments with id equal to {$in: commentIds}. what does {$in: commentIds} mean?
comments: function () {
var commentIds = this.commentIds || [ ];
return Comments.find({_id: {$in: commentIds}}, {sort: {‘createdAt’: -1}});
},
Thanks in advance