0
DBClientConnectionクラスを使用する代わりに、DBClientBaseクラスを使用しています。私は正常にDBに接続することができますが、文書を挿入することはできません。ここでMongoDB C++ドライバでDBClientBaseクラスを使用してドキュメントを挿入する方法は?
は私のコードは、コンパイラがエラーrequest for member ‘insert’ in ‘conn’, which is of non-class type ‘mongo::DBClientBase*’
を与える
DBClientBase *conn = NULL;
string err_msg;
ConnectionString cs = ConnectionString::parse(connString, err_msg);
if (!cs.isValid()) {
throw "bad: " + err_msg;
}
try {
conn = cs.connect(err_msg);
} catch (DBException &e) {
cout << "caught " << err_msg << endl;
return 1;
}
if (!conn){
cout<<"Unable to connect to DB"<<endl;
return 1;
}
BSONObjBuilder b;
b.append("name", "Joe");
b.append("age", 33);
BSONObj p = b.obj();
conn.insert("db.coll",p,0);
like-どのように見えるかどこかに文書を挿入するためにDBClientBaseクラスの使用方法の例がありますか?
また、私が述べたhere