" Phone " " 13800138123 " " 13800138124 " ) )
Using SEQUOIADB to develop C + + applications requires the use of Bson objects, this article mainly on the bson of the operation of Things
1: Build a _id Bson object
Bson's C + + driver gives me a macro bson that makes it easy to build a Bson object, but there's a pit that doesn't build--id Bson objects
Bsonobj Obj=bson ("_id" <<bson ("$oid"<<" xxx"));
Use this statement to create a Bson, when looking for, can not find data (error, forget). The right approach should be.
Bsonobjbuilder builder; OID oid (inst_id);
Bosonobj condition=builder.appendoid ("_id"// StringData types can be replaced with string types and char*
2: Build a Bson, value is an array
Data format {"num": [33,44]}
Bsonarraybuilder nums; Bsonobjbuilder arr;nums<<<<arr.append ("num ", Nums.arr ());
Note that above Bsonarraybuilder cannot use the Done method, which generates a map array
You can also use macros
" Phone " " 13800138123 " " 13800138124 " ) )
These classes and macros are all under namespace Bson.
C + + application development for SEQUOIADB 1