I'm having trouble running the upsert on the mongo when I connect in 3 shards in cpp. Now when I connect in only one of the shards I can do the operation. Does anyone have an alternative or do you know the reason for this error?
CODE:
ConnectionString cs("mongodb://host:pass@server1:27017,server2:27017,server3:27017", ConnectionString::ConnectionType::SYNC);
DBClientBase *conn = cs.connect( mongo_erro );
BSONObjBuilder bojUpsert;
bojUpsert.append("teste","1234567890");
bojUpsert.append("valor",123);
conn->update("xxx.xxx", Query("{teste:\"1234567890\"}") , bojUpsert.obj() , mongo::UpdateOptions::UpdateOption_Upsert);
ERROR:
terminate called after throwing an instance of 'mongo :: UserException' what (): SyncClusterConnection :: update upsert query needs _id
I'm using linux mint , QT 4.8.6 + libmongo-client-dev 0.1.7-1