I am using Mongoskin together with Javascript and have achieved some great results so far, until I got issues with combining two different parts of it.
When using findOne() with update(), I get an error message I am not sure about. I think there might be something wrong with how I am handling the callback. When using findOne I can see the results from it, but when passing it down to the update-function it fails. Since the error message mentions it needs a valid Javascript object, my first thought is that the update-function is called too early or something...
db.collection('colname').findOne({}, function (err, result) {
db.collection('colname').update({
$set: {
"thirdArray.3": result.firstArray[7],
"fourthArray.3": result.secondArray[7]
}
});
});
and the error message:
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1):
MongoError: document must be a valid JavaScript object