Convert Bson to string - MongoDB/Javascript

bson, javascript, mongodb, string

Solution

You can use the `tojson` function like so:

str = tojson(db.mycol.stats());

Problem

how do I convert a bson obj to a string? I read Convert MongoDB BsonDocument into a string but that's for c#. I'm using Javascript for Mongodb It would be applied at something like this: ``` myvar = db.mycol.stats(); ```

Original source