In the previous call of Object.bsonsize()
, Mongodb returned the size of the cursor, rather than the document.
Correct way is to use this command:
Object.bsonsize(db.test.findOne())
With findOne()
, you can define your query for a specific document:
Object.bsonsize(db.test.findOne({type:"auto"}))
This will return the correct size (in bytes) of the particular document.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…