如果我不在我的 aws ubuntu 14.04 机器上使用收缩包装或纱线,我的查询工作正常。
但是,相同的查询可以在本地机器上使用 shrinkwrap/yarn,但不知何故,它们在 aws 机器上不起作用。
查询如下图:
var express = require('express');
var mongoose = require('mongoose');
var bodyParser = require('body-parser');
var foodtr = require('./../model/foodtruck');
var foodtrucklist = function(req, res) {
foodtr.find().populate('item_list').exec(function(err, foodtrucks) {
foodtrucks.forEach(function(ftr) {
var start_time = ftr.foodtruck_starting_timing;
var end_time = ftr.foodtruck_closing_timing;
var foodtruck_open_status = ftr.foodtruck_open_status;
// var shut_down = ftr.foodtruck_shutdown;
if ((start_time && end_time) &&
(start_time.trim() != '' &&
end_time.trim() != '')) {
if (inTime(start_time, end_time) &&
foodtruck_open_status ==0 ) {
ftr.foodtruck_open_status = 0;
ftr.save();
} else {
ftr.foodtruck_open_status = 1;
ftr.save();
}
}
})
res.json({
status: '200',
message: 'foodtrucklist',
data: foodtrucks
});
});
};
我得到的错误是:
events.js:160
throw er; // Unhandled 'error' event
^
TypeError: Cannot read property 'forEach' of undefined
at /home/bitnami/quflipNodeAPI/controller/foodtrucklist.js:9:19
at /home/bitnami/quflipNodeAPI/node_modules/mongoose/lib/query.js:2745:9
at newTickHandler (/home/bitnami/quflipNodeAPI/node_modules/mpromise/lib/promise.js:234:18)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)