最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

类型错误:无法读取性能在EventEmitter的不确定的“应用”

IT培训 admin 7浏览 0评论

类型错误:无法读取性能在EventEmitter的不确定的“应用”

我建立一个节点JS与DHTMLX调度应用程序的一个页面。然而,whenver页面加载,应用程序崩溃,并且我收到以下错误:

类型错误:无法读取性能在EventEmitter的不确定的 '应用'(/ node_modules / mongoskin / lib中/ collection.js:52:21)。)

下面是该模块的错误引用:

  SkinCollection.prototype._open = function(callback) {
    var collection_args = this._collection_args.concat([callback]);
    this._skin_db.open(function(err, db) {
        if(err) return callback(err);
        db.collection.apply(db, collection_args);
    });
  }

这里是导致该错误,当我不包括此代码日历不会崩溃的应用程序中的我app.js的一部分,但我没有将数据发送到我的MongoDB集群图谱的方式。

app.js

    app.use(express.static(path.join(__dirname, 'public')));
    app.use(bodyParser.json());
    app.use(bodyParser.urlencoded({ extended: true }));

    app.get('/init', function(req, res){
        db.event.insert({ 
            text:"My test event A", 
            start_date: new Date(2018,8,1),
            end_date:   new Date(2018,8,5)
        });
        db.event.insert({ 
            text:"My test event B", 
            start_date: new Date(2018,8,19),
            end_date:   new Date(2018,8,24)
        });
        db.event.insert({ 
            text:"Morning event", 
            start_date: new Date(2018,8,4,4,0),
            end_date:   new Date(2018,8,4,14,0)
        });
        db.event.insert({ 
            text:"One more test event", 
            start_date: new Date(2018,8,3),
            end_date:   new Date(2018,8,8),
            color: "#DD8616"
        });

        res.send("Test events were added to the database")
    });


    app.get('/data', function(req, res){
        db.event.find().toArray(function(err, data){
            //set id property for all records
            console.log(err);
            for (var i = 0; i < data.length; i++)
                data[i].id = data[i]._id;

            //output response
            res.send(data);
        });
    });


    app.post('/data', function(req, res){
        var data = req.body;
        var mode = data["!nativeeditor_status"];
        var sid = data.id;
        var tid = sid;

        delete data.id;
        delete data.gr_id;
        delete data["!nativeeditor_status"];


        function update_response(err, result){
            if (err)
                mode = "error";
            else if (mode == "inserted")
                tid = data._id;

            res.setHeader("Content-Type","application/json");
            res.send({action: mode, sid: sid, tid: tid});
        }

        if (mode == "updated")
            db.event.updateById( sid, data, update_response);
        else if (mode == "inserted")
            db.event.insert(data, update_response);
        else if (mode == "deleted")
            db.event.removeById( sid, update_response);
        else
            res.send("Not supported operation");
    });

我只学了过去一周的JavaScript和很新的编码。我不明白为什么这个错误是发生。当我运行调度程序作为一个独立的功能它完美的作品。只有当我尝试实施它在我的网站上它抛出这个错误。

回答如下:

更新:正确答案

这个问题是一个重复:MongoSkin "Cannot read property 'apply' of undefined"

Mongoskin只支持MongoDB的2.x中,使用MongoDB的3.x的时候发生这个错误

原件(不正确)答案

漂亮的新的MongoDB自己,但我敢肯定,问题是,你需要在此线路上表的实际名称替换collection

db.collection.apply(db, collection_args);

因此,例如,如果表/集的名字是skin,行会变成:

db.skin.apply(db, collection_args);

(请注意如何当app.j执行对事件表DB操作,它在调用db.event.insert(),等...)

类型错误:无法读取性能在EventEmitter的不确定的“应用”

我建立一个节点JS与DHTMLX调度应用程序的一个页面。然而,whenver页面加载,应用程序崩溃,并且我收到以下错误:

类型错误:无法读取性能在EventEmitter的不确定的 '应用'(/ node_modules / mongoskin / lib中/ collection.js:52:21)。)

下面是该模块的错误引用:

  SkinCollection.prototype._open = function(callback) {
    var collection_args = this._collection_args.concat([callback]);
    this._skin_db.open(function(err, db) {
        if(err) return callback(err);
        db.collection.apply(db, collection_args);
    });
  }

这里是导致该错误,当我不包括此代码日历不会崩溃的应用程序中的我app.js的一部分,但我没有将数据发送到我的MongoDB集群图谱的方式。

app.js

    app.use(express.static(path.join(__dirname, 'public')));
    app.use(bodyParser.json());
    app.use(bodyParser.urlencoded({ extended: true }));

    app.get('/init', function(req, res){
        db.event.insert({ 
            text:"My test event A", 
            start_date: new Date(2018,8,1),
            end_date:   new Date(2018,8,5)
        });
        db.event.insert({ 
            text:"My test event B", 
            start_date: new Date(2018,8,19),
            end_date:   new Date(2018,8,24)
        });
        db.event.insert({ 
            text:"Morning event", 
            start_date: new Date(2018,8,4,4,0),
            end_date:   new Date(2018,8,4,14,0)
        });
        db.event.insert({ 
            text:"One more test event", 
            start_date: new Date(2018,8,3),
            end_date:   new Date(2018,8,8),
            color: "#DD8616"
        });

        res.send("Test events were added to the database")
    });


    app.get('/data', function(req, res){
        db.event.find().toArray(function(err, data){
            //set id property for all records
            console.log(err);
            for (var i = 0; i < data.length; i++)
                data[i].id = data[i]._id;

            //output response
            res.send(data);
        });
    });


    app.post('/data', function(req, res){
        var data = req.body;
        var mode = data["!nativeeditor_status"];
        var sid = data.id;
        var tid = sid;

        delete data.id;
        delete data.gr_id;
        delete data["!nativeeditor_status"];


        function update_response(err, result){
            if (err)
                mode = "error";
            else if (mode == "inserted")
                tid = data._id;

            res.setHeader("Content-Type","application/json");
            res.send({action: mode, sid: sid, tid: tid});
        }

        if (mode == "updated")
            db.event.updateById( sid, data, update_response);
        else if (mode == "inserted")
            db.event.insert(data, update_response);
        else if (mode == "deleted")
            db.event.removeById( sid, update_response);
        else
            res.send("Not supported operation");
    });

我只学了过去一周的JavaScript和很新的编码。我不明白为什么这个错误是发生。当我运行调度程序作为一个独立的功能它完美的作品。只有当我尝试实施它在我的网站上它抛出这个错误。

回答如下:

更新:正确答案

这个问题是一个重复:MongoSkin "Cannot read property 'apply' of undefined"

Mongoskin只支持MongoDB的2.x中,使用MongoDB的3.x的时候发生这个错误

原件(不正确)答案

漂亮的新的MongoDB自己,但我敢肯定,问题是,你需要在此线路上表的实际名称替换collection

db.collection.apply(db, collection_args);

因此,例如,如果表/集的名字是skin,行会变成:

db.skin.apply(db, collection_args);

(请注意如何当app.j执行对事件表DB操作,它在调用db.event.insert(),等...)

发布评论

评论列表 (0)

  1. 暂无评论