How’s the performance of MongoDB’s $or with Meteor?
Which pattern would probably be better for a Meteor application?:
Pattern 1
//client
Meteor.subscribe('friday-docs')
Meteor.subscribe('saturday-docs')
Meteor.subscribe('sunday-docs')
//server
Meteor.publish('friday-docs', function(){
return Docs.find({'times.friday':{$lte:12, $gte: 6}})
})
Meteor.publish('friday-docs', function(){
return Docs.find({'times.saturday':{$lte:12, $gte: 6}})
})
Meteor.publish('friday-docs', function(){
return Docs.find({'times.sunday':{$lte:12, $gte: 6}})
})
Pattern 2
//client
Meteor.subscribe('all-docs')
//server
Meteor.publish('all-docs', function(){
var orQuery = [
{'times.friday':{$lte:12, $gte: 6}},
{'times.saturday':{$lte:12, $gte: 6}},
{'times.sunday':{$lte:12, $gte: 6}}
]
return Docs.find({$or:orQuery})
})