I've been modifying Telescope to search for posts with two categories.
To do this I passed an object with the categories through my PostsListController
in router.js
and modified parameters.js
by adding the following:
if (terms.categories) {
_.extend(parameters.find, {$and: [{'categories.slug': terms.categories[0]},
{'categories.slug': terms.categories[1]}]});
}
This seems like an ugly way to do this. What is the more "meteor-y" way to do this?
This is more of a mongodb question I think. Their operator reference docs are here .
Besides $and mongo provides $all which is a shorter and slightly more clear.
_.extend(parameters.find, {'categories.slug': { $all: terms.categories }});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.