C + + application development for SEQUOIADB 1

Source: Internet
Author: User

" 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.