Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js mongoose paginate给定错误没有方法';分配';_Node.js_Mongodb_Pagination - Fatal编程技术网

Node.js mongoose paginate给定错误没有方法';分配';

Node.js mongoose paginate给定错误没有方法';分配';,node.js,mongodb,pagination,Node.js,Mongodb,Pagination,我正在使用mongoose paginate进行分页,它在我的系统上运行良好,但当我将其部署到服务器上时,会出现错误 TypeError: Object function Object() { [native code] } has no method 'assign' at Function.paginate (/home/ubuntu/klickbrick_api_web/node_modules/mongoose-paginate/index.js:20:22) at expo

我正在使用mongoose paginate进行分页,它在我的系统上运行良好,但当我将其部署到服务器上时,会出现错误

TypeError: Object function Object() { [native code] } has no method 'assign'
   at Function.paginate (/home/ubuntu/klickbrick_api_web/node_modules/mongoose-paginate/index.js:20:22)
   at exports.getRequest (/home/ubuntu/klickbrick_api_web/server/api/bookSiteVisit/bookSiteVisit.Controller.js:92:21)
   at Layer.handle [as handle_request] (/home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/layer.js:95:5)
   at next (/home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/route.js:131:13)
   at Route.dispatch (/home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/route.js:112:3)
   at Layer.handle [as handle_request] (/home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/layer.js:95:5)
   at /home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/index.js:277:22
   at Function.process_params (/home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/index.js:330:12)
   at next (/home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/index.js:271:10)
   at Function.handle (/home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/index.js:176:3)
   at router (/home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/index.js:46:12)
   at Layer.handle [as handle_request] (/home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/layer.js:95:5)
   at trim_prefix (/home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/index.js:312:13)
   at /home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/index.js:280:7
   at Function.process_params (/home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/index.js:330:12)
   at next (/home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/index.js:271:10)
   at process.env.NODE_ENV (/home/ubuntu/klickbrick_api_web/server/server.js:30:12)
   at Layer.handle [as handle_request] (/home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/layer.js:95:5)
   at trim_prefix (/home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/index.js:312:13)
   at /home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/index.js:280:7
   at Function.process_params (/home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/index.js:330:12)
   at next (/home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/index.js:271:10)
   at cookieParser (/home/ubuntu/klickbrick_api_web/node_modules/cookie-parser/index.js:70:5)
   at Layer.handle [as handle_request] (/home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/layer.js:95:5)
   at trim_prefix (/home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/index.js:312:13)
   at /home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/index.js:280:7
   at Function.process_params (/home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/index.js:330:12)
   at next (/home/ubuntu/klickbrick_api_web/node_modules/express/lib/router/index.js:271:10)
这是我的模型

var mongoose = require('mongoose');
var mongoosePaginate = require('mongoose-paginate');
var Schema = mongoose.Schema;

var CustomerRequestSchema = new Schema({
    //projects: [{ type: Schema.ObjectId, ref: "Project" }],
    representativeName: String,
    customerName: String,
    email: String,
    phone: Number,
    comment: String,
    project: String,
    requestType: String,
    createdAt: { type: Date, 'default': Date.now },
});
CustomerRequestSchema.plugin(mongoosePaginate);
module.exports = mongoose.model('CustomerRequest', CustomerRequestSchema);
获取如下数据

 CustomerRequest.paginate({}, { page: req.body.page || 1, limit: req.body.limit || 10, sort: { createdAt: -1 }, }, function (error, requestTypes) {
        if (error) return res.send(error);
        res.send(requestTypes);
    });

您应该发布一些引用代码服务器上的节点版本可能太旧。您应该发布一些引用代码服务器上的节点版本可能太旧。