Debug mongodb - ReferenceError: Console not defined
I got the file js
to work in mongodb
, where I got the console.log
debug expression :
use test;
db.city.find().snapshot().forEach(function(city){
var Pos = city.Pos;
if (Pos)
{
longLat = Pos.split(" ");
console.log("longLat"); // for debugging ----------------------------
console.log(longLat);
lon = longLat[0];
lat = longLat[1];
if (lon && lat)
{
lon = parseFloat(lon);
lat = parseFloat(lat);
longLat = [lon, lat];
city.longLat = longLat;
}
}
db.orgs.save(city);
})
When I ran it ...
mongo < /path/to/this/js/file.js
... I got an error in the output:
ReferenceError: console is not defined
Is there a way to log intermediate results for debugging purposes?
+3
source to share