Reputation: 23
I'll give a code example to describe my problem:
var id = Collection.insert({
name: 'Charles Darwin',
likes: 1
});
var someVariable = 'name';
Collection.findOne(id).name // This returns 'Charles Darwin', but how do I use someVariable to get the same result?
Collection.findOne(id).someVariable // This will certainly not work, but what is the right way to do it?
Upvotes: 2
Views: 2307
Reputation: 103475
Try accessing the object property using the bracket notation:
Collection.findOne(id)[someVariable];
Upvotes: 5