I need help with searching MongoDB using findOne (or find). I am having trouble accessing a value from within the record, possibly because it's a child object?
Specifically, I am trying to retrieve the order_number field which returns null. However, when using the domain field, it works successfully!
The order_number can be found within the customer_details object.
Here is the database function I am currently using:
dbconnect.createConnection()
refund.findOne({domain: domain, order_number: order_number}, (err, docs) => {
console.log('database return in addRefund ' + docs)
dbconnect.closeConnection();
})
(Even if the order_number exists, it still returns null)
Here is the object structure:
{
"_id": {
"$oid": "5c83d0d5ce02f50019b1b146"
},
"refundDetails": {
// ommitted for brevity
},
"customer_details": [
{
"order": {
// ommitted for brevity
}
}
],
"domain": "dwdwd.wdwd.com",
"__v": 0
}
Your assistance on this issue would be highly appreciated. Thank you!