Hi,
thanks for your answer.
I tried the same on the mongo console and there speed stays an Int:
for (var i = 1; i <= 5; i++) {
for (var j = 1; j <= 50; j++) {
db.testcoll.insert({"vehicleId":j, "timestamp":new Date(),
"speed":j})
}
}
db.testcoll.group (
{key: {vehicleId: true},
reduce: function(doc, prev) {
if (doc.timestamp > prev.timestamp) {
prev.vehicleId = doc.vehicleId;
prev.timestamp = doc.timestamp;
prev.speed = doc.speed;
}
},
initial: {timestamp: 0}
})
What do you think about it?
Cheers,
Christian