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.
- Host: GitHub
- URL: https://github.com/mapx/mongodb-utils
- Owner: mapx
- Created: 2013-05-31T03:18:41.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2013-06-02T14:59:24.000Z (about 13 years ago)
- Last Synced: 2025-02-21T20:31:48.243Z (over 1 year ago)
- Language: C
- Homepage:
- Size: 125 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.