mongodb - Java driver equivalent for JavaScript shell's Object.bsonsize( doc )? -


i wondering java driver's equivalent mongo javascript shell's object.bsonsize( doc ) method? example, java code perform following:

bobk-mbp:~ bobk$ mongo mongodb shell version: 2.0.4 connecting to: test primary> use devices; switched db devices primary> object.bsonsize( db.profiles.findone( { _id: "rek_0001" } ) ); 186 primary> object.bsonsize( db.profiles.findone( { _id: "rek_0002" } ) ); 218 primary>  

how perform same basic use case mongodb java driver. not obvious through javadocs.

there's nothing quite clean what's available in shell, work:

dbobject obj = coll.findone(); int bsonsize = defaultdbencoder.factory.create().         writeobject(new basicoutputbuffer(), obj)); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -