node.js - What am I doing wrong trying to make this run with meteor? -


i trying adapt full text search made here work meteor. exported mongodb url 1 running 2.6.1. make full text search compatible getting these errors server/search.js:2:15: unexpected token .andserver/search.js:42:7: unexpected token ). missing?

server.js

meteor.methods({     meteor.ensureindex("posts", {       smaintext: "text"     }, function(err, indexname) {       assert.equal(null, err);     });   ) };   meteor.methods({     feedupdate: function(req) {       posts.find({         "$text": {           "$search": req         }       }, {         smaintext: 1,         submitted: 1,         _id: 1,         posts: {           $meta: "posts"         }       }, {         sort: {           textscore: {             $meta: "posts"           }         }       }).toarray(function(err, items) {         (e=0;e<101;e++) {         meteor.users.update({           "_id": this.userid         }, {           "$addtoset": {             "profile.search": item[e]._id           }         });      }       })     }   ) }; 

this wrong definition of method

meteor.methods({ meteor.ensureindex("posts", {   smaintext: "text" }, function(err, indexname) {   assert.equal(null, err); }); 

) };

you must specify method name ( http://docs.meteor.com/#/basic/meteor-methods ) this
meteor.methods({ mymethodname : function() { meteor.ensureindex("posts", { smaintext: "text" }, function(err, indexname) { assert.equal(null, err); }); } });

in second method there semicron , parenthise problem. correct version

meteor.methods({ feedupdate: function(req) {   posts.find({     "$text": {       "$search": req     }   }, {     smaintext: 1,     submitted: 1,     _id: 1,     posts: {       $meta: "posts"     }   }, {     sort: {       textscore: {         $meta: "posts"       }     }   }).toarray(function(err, items) {     (e=0;e<101;e++) {     meteor.users.update({       "_id": this.userid     }, {       "$addtoset": {         "profile.search": item[e]._id       }     });  }   }); } 

});


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -