shingara
shingara

Reputation: 46914

How I know my document's size inside MongoDB with the ruby driver

The limitation of one document in MongoDB is 4Mo. I have some documents really heavy with a lot of data.

How I know my document's size inside MongoDB with the ruby driver ?

Upvotes: 10

Views: 6176

Answers (2)

Zack Bartel
Zack Bartel

Reputation: 3713

Or native Object.bsonsize(db.Foo.findOne());

Upvotes: 28

kris
kris

Reputation: 23592

You can use BSON.serialize and find the length of the resulting byte buffer. See http://www.mongodb.org/display/DOCS/BSON#BSON-Ruby for an example of using BSON.serialize.

Upvotes: 4

Related Questions