我现在想给一个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);
结果出错了。我想问二进制的数据怎么插入呢。求例子
You have to use a BSONObjBuilder
The
0x00
you have here is actually a string, and what you want to insert is the value of0x00
, which is0
.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