An open API service indexing awesome lists of open source software.

https://github.com/mapx/mongodb-utils

Mongodb utilities, including debug tools and improved BSONObj builder macros.
https://github.com/mapx/mongodb-utils

Last synced: 11 months ago
JSON representation

Mongodb utilities, including debug tools and improved BSONObj builder macros.

Awesome Lists containing this project

README

          

mongodb-utils
=============

Mongodb utilities.

Improved BSONObj Builder Macros

BSONS

A macro to build a BSONObj of custom initial buffer size from a stream to reduce memory allocation times.


e.g.,

BSONS(32, "name" << "joe" << "age" << 33 )


with auto-generated object id:


BSONS(64, GENOID << "name" << "joe" << "age" << 33 )


when size is 64, it is the same as:


BSON(GENOID << "name" << "joe" << "age" << 33 )


The labels GT, GTE, LT, LTE, NE can be helpful for stream-oriented construction
of a BSONObj, particularly when assembling a Query. For example,


BSONS(96, "a" << GT << 23.4 << NE << 30 << "b" << 2 ) produces the object
{ a: { $gt: 23.4, $ne: 30 }, b: 2 }.



QUERYS

QUERY's custom initsize version.




BSONS_ARRAY

Use BSONS_ARRAY macro like BSONS macro, but without keys


BSONArray arr = BSONS_ARRAY(128, "hello" << 1 <<

BSON("foo" << BSONS_ARRAY(32, "bar" << "baz" << "qux" ) ) );



Debug Helpers

SHOW_BSON_BOB
Print bson::bob object content in DEBUG mode.


SHOW_BSON_BO
Print bson::bo object content in DEBUG mode.


SHOW_BSON_BE
Print bson::be object content in DEBUG mode.


SHOW_MONGODB_LASTERR
Print a mongodb connection's last error in DEBUG mode.