I'm stuck at reading out nested JSON elements that were saved in a MongoDB. I'm trying it with the following method:
blockChainModel.find({"transactions.user": "eltaieyo"}, null, {projection : { transactions: {user : 1}} }, (err, blocks) => {
if (err) console.error("Cannot find the specified Blocks");
console.log(blocks);
});
The JSON in the MongoDB, that I'm trying to read looks like this: JSON Image
I want to read out the "transactions" section, and this is what the current method in my Code does: OUTPUT Image
Maybe It is reading them out but my method doesn't give them out correctly?
CodePudding user response:
How about remove projection
and try again to check if there is actually some data return ?