mongodb c++驱动如何插入二进制数据?
PHPz
PHPz 2017-04-17 14:28:46
0
3
577

我现在想给一个documents里边某一个字段设定二进制数据并且插入数据库。
我说的不是整个二进制文件。
想用一下方式传入数据
DBClientConnection oDB;
const std::string test =

        "{insert: \"test1\", documents: [{\"_id\" : 6,\"name\":\"vector6\",\"value\":0x00}]}";

bool runret = oDB.runCommand("wjhtest", mongo::fromjson(test), p2, 0);

结果出错了。我想问二进制的数据怎么插入呢。求例子

PHPz
PHPz

学习是最好的投资!

reply all(3)
洪涛

You have to use a BSONObjBuilder

小葫芦

The 0x00 you have here is actually a string, and what you want to insert is the value of 0x00, which is 0.
So you need to convert your 0x00 into a string, i.e. "value":0

阿神

What if I want to insert a file at value? How to write it

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!