I have a collection in Meteor.js with properties that include a timestamp. For instance:
Posts.insert({
category: 'type1',
text: 'hello world',
time: new Date(2012, 2, 14, 15, 25),
});
I know that I can filter the assembly by matching a parameter, for example.
Meteor.subscribe('posts', 'type1');
Meteor.publish('posts', function(category) {
return Posts.find({category: category});
});
However, I also want to be able to filter in more complex ways: 1) by the “time” field, for example. all positions between January 1, 2012 and January 1, 2013. 2) by searching for all messages that have certain words, for example. "world" in the "text" field.
What is the right way to do this?
source
share