Unexpected behaviour while adding an item to an array in a BSON document that has come from Mongoose query
Actually, you're doing nothing wrong, but console.log()
only recurses into nested objects up to a certain depth:
> console.log([[[ "test" ]]])[ [ [ 'test' ] ] ]// add one more level, and...> console.log([[[[ "test" ]]]])[ [ [ [Object] ] ] ]
Try converting your object to (pretty-printed) JSON:
console.log(JSON.stringify(user, null, 2));
Or, alternatively, use a formatting string (output won't be as pretty though):
console.log('%j', user);
Or use util.inspect
with an specified depth (where null
means infinite
):
var inspect = require('util').inspect;console.log(inspect(a, { depth : null }))