Answer the question
In order to leave comments, you need to log in
Where did I go wrong in node.js?
Good time of the day. Strongly do not kick :) I can not understand where I made a mistake. I have a mongo schema
module.exports = function() {
var LocationObject = new Schema({
user_id: String,
loc: {type: {type: String},coordinates: []},
timestamp: String,
hdop: String,
altitude: String,
speed: String
});
// define the index
LocationObject.index({loc: '2dsphere'});
mongoose.model('Location', LocationObject);
};
router.get('/gps/loc*', function(req, res) {
var data = [
user_id = req.params.user_id,
lat = req.params.lat,
lon = req.params.lon,
timestamp = req.params.timestamp,
hdop = req.params.hdop,
altitude = req.params.altitude,
speed = req.params.speed
];
async.each(data, function(item, cb) {
Location.create(item, cb);
console.log(data);
}, function(err) {
if (err) {
throw err;
}
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question