-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 3.2.3
-
Component/s: None
-
Empty show more show less
I'm executing a simple insertOne (using the Promise version of the API) and looking at the result object with JSON.stringify(), but instead of an object with 5 properties (insertedCount, ops, insertedId, connection, result as specified here), I'm seeing an object with only 2 properties (ok, n). Those two are the properties of "insertOneWriteOpResult.result", but why is JSON.stringify only displaying that sub-property instead of the full object? It causes confusion when using the insertOneWriteOpResult object.
const client = await MongoClient.connect(my_connection_string); return client.db('my-db').collection('my-collection') .insertOne(myDoc) .then(resultObject => { // The following line prints {"n":1,"ok":1} console.log(JSON.stringify(resultObject)); // But the following line prints undefined console.log(resultObject.ok); // And this one correctly prints 1 console.log(resultObject.result.ok); });