I got js
file to run within mongodb
where I got console.log
expression for debugging:
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 run it...
mongo < /path/to/this/js/file.js
... I got error in the output:
ReferenceError: console is not defined
Is there any way to log intermediate results for debugging purposes?