Object.bsonsize is not a function

Note the warning at the top of the documentation page you linked:

The following document pertains to the mongo shell, included in the MongoDB Server Download. For information on the new MongoDB Shell ( mongosh ) refer to the mongosh documentation.

In this specific case, you can just use bsonsize(doc) and don’t need the Object. prefix.

2 Likes