Using a js
file within mongodb
, I implemented a code snippet containing a console.log
expression for debugging purposes:
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);
})
Upon executing the script using:
mongo < /path/to/this/js/file.js
An error message is returned:
ReferenceError: console is not defined
Is there an alternative method to log interim results during debugging?