Hello.
I have this code.
Template.body.events({
"submit .new-task": function (event) {
// Prevent default browser form submit
event.preventDefault();
// Get value from form element
var text = event.target.text.value;
// Insert a task into the collection
EventDB.insert({
text: text,
createdAt: new Date() // current time
});
// Clear form
event.target.text.value = "";
}
it works great, it populates my todo list with events as expected.
Now i want to make a sort function that shows only tasks that have cucumber in it and i dont get it to work.
I have read alot of different posts about it but still no luck as they always speak about old mongoDB etc.
I can sort the list by date created without any issues.
return EventDB.find({}, {sort: {createdAt: -1}});
But now i want to try to sort it by text, i have tried for example
return EventDB.find({$text:{$search:"Cucumber"}});
But it removes everything on my list instead of only showing events with Cucumber in the text.
I have read something about that i need to index the DB but when i try that i get compilation errors instead.
What would be the correct way?
Can i get some help how to make a sort by text search?
Im following the todo list tutorials for your refference.
BR
Dimi