简体   繁体   中英

How to call function from MongoDB in Meteor.js?

I would like to call functions that I have defined in MongoDB with Meteor.js? For example I have a function call hi() in MongoDB. To call it in MongoDB I use this command:

> db.eval('hi()')

What about in Meteor?

var funcInputObj={};var mongoFuncName='testfunc';
 MongoInternals.defaultRemoteCollectionDriver().mongo.db.eval('db.loadServerScripts();return ' + mongoFuncName+ '(' + JSON.stringify(funcInputObj|| {}) + ');',function (err, mongoFuncReturnData) {


   console.log(mongoFuncReturnData);
 });

Unless someone contradicts me it is not possible yet. Meteor doesn't let you "play" with all Mongo functions.

There are some tracks you can read and dig here .

I wish I could have helped you more, good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM