Javascript MeteorJS错误“;无效的修饰符。修饰符必须是对象";

Javascript MeteorJS错误“;无效的修饰符。修饰符必须是对象";,javascript,node.js,meteor,npm,Javascript,Node.js,Meteor,Npm,当删除包含UserSession.insert的if语句时,一切正常。但是当它被排除时,我们得到一个关于无效修饰符的错误 出了什么问题?谢谢大家! 服务器/助手/b.s Meteor.startup(function(){ // Initialize var SUPERPACK = Meteor.require('superpack'); var superpack = new SUPERPACK('a', 'b'); // Get Account Info

当删除包含
UserSession.insert
if
语句时,一切正常。但是当它被排除时,我们得到一个关于无效修饰符的错误

出了什么问题?谢谢大家!

服务器/助手/b.s

Meteor.startup(function(){

    // Initialize
    var SUPERPACK = Meteor.require('superpack');
    var superpack = new SUPERPACK('a', 'b');


    // Get Account Info
    try {
        superpack.getInfoSync = Meteor._wrapAsync(superpack.getInfo.bind(superpack));
        var data = superpack.getInfoSync();

        // THIS PART WHEN REMOVED, REMOVES THE ERROR *********
        // Update if record exist, create if not
        if (UserSession.find().count() == 0) {

            UserSession.insert({ 'userId': 1, 'account': data});

        } else {

            UserSession.update({ 'userId': 1, 'account': data});

        }

        console.log(data);

    } catch(error) {
        console.log(error);
    }

});
错误:

superpack.getInfoSync(): Error: Invalid modifier. Modifier must be an object.

似乎有两个错误:

第一个是带有
if
语句的:

if (UserSession.find().count() > 0) {
应改为

if (UserSession.find().count() == 0) {
第二个:对于
update()

从文件:

collection.update(selector, modifier, [options], [callback])

必须提供选择器和修饰符。

如果语句和会话Session.set()?@AntoJurkovic我添加了另一行注释来标记该部分代码。对不起,我是说“UserSession.insert”这个规则
…count()>0
可以吗?首先,我希望
update()
之后呢?@AntoJurkovic你说得对。我已将其更改为
if(…count()==0)
。原始错误仍然存在。您似乎还需要对
update()
函数:
collection.update(选择器、修饰符、[options]、[callback])进行一些修改。
collection.update(selector, modifier, [options], [callback])