Skip to content

Instantly share code, notes, and snippets.

@SachaG
Created June 19, 2013 08:49
Show Gist options
  • Save SachaG/5812762 to your computer and use it in GitHub Desktop.
Save SachaG/5812762 to your computer and use it in GitHub Desktop.
Meteor.methods({
searchPosts: function(term) {
console.log('-- searching for "'+term+'" --')
Future = Npm.require('fibers/future');
var fut = new Future();
Meteor._RemoteCollectionDriver.mongo.db.executeDbCommand({
"text": "posts",
search: term
}, function (error,results){
if (results && results.documents[0].ok === 1){
fut.ret(results)
}
});
var results = fut.wait();
SearchResults.remove();
_.each(results.documents[0].results, function(item){
console.log(item)
SearchResults.insert(item.obj);
});
return results;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment