Hey guys I have this method in my collection
collections/fritkots.js
Fritkots.search = function(query) {
return Fritkots.find({
name: { $regex: RegExp.escape(query), $options: ‘i’ }
}, {
limit: 1
});
}
And in my template helpers I’m calling it like
search.js
Template.search.helpers({
searchResults: () => {
return Fritkots.search(Session.get(‘fritkotsSearchQuery’));
However I would like to just create a Meteor Method
and the just do Meteor.call('search')
but for some reason is not working. Could someone help ? Thanks
This is what I would like to do Not Working
#####collections/fritkots.js
search: (query) => {
if (Fritkots.find({}).count() > 0 ) {
return Fritkots.find({
name: { $regex: RegExp.escape(query), $options: ‘i’ }
}, {
limit: 3
});
} else {
throw new Meteor.Error(‘nothing-found’, ‘We were unable to do the query’);
}
search/search.js
Template.search.helpers({
searchResults: () => {
return Meteor.call(‘search’, Session.get(‘fritkotsSearchQuery’));