Is there any way how to use long integer data type in Mongo shell?
db.users_stats.find().forEach(function(row) {
var newRow = row;
newRow.user_id = new NumberLong(row.user_id);
newRow.date = new Date(row.date);
printjson(newRow);
});
JS Error: TypeError: NumberLong is not a constructor mongoConvert.js:3
db.users_stats.find().forEach(function(row) {
var newRow = row;
newRow.app_id = NumberLong(row.user_id);
newRow.date = new Date(row.date);
printjson(newRow);
});
JS Error: TypeError: NumberLong is not a function mongoConvert.js:3
Yes, it should work fine. The errors you’re seeing are wicked, I can’t reproduce them. Which version are you using? In
1.8.1, I can’t reproduce the “NumberLongis not a constructor” error.The following works for me: