本文整理汇总了C++中poco::SharedPtr::documents方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedPtr::documents方法的具体用法?C++ SharedPtr::documents怎么用?C++ SharedPtr::documents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类poco::SharedPtr
的用法示例。
在下文中一共展示了SharedPtr::documents方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testCursorRequest
void MongoDBTest::testCursorRequest()
{
Poco::MongoDB::Database db("team");
Poco::SharedPtr<Poco::MongoDB::InsertRequest> insertRequest = db.createInsertRequest("numbers");
for(int i = 0; i < 10000; ++i)
{
Document::Ptr doc = new Document();
doc->add("number", i);
insertRequest->documents().push_back(doc);
}
_mongo->sendRequest(*insertRequest);
Poco::Int64 count = db.count(*_mongo, "numbers");
assert(count == 10000);
Poco::MongoDB::Cursor cursor("team", "numbers");
int n = 0;
Poco::MongoDB::ResponseMessage& response = cursor.next(*_mongo);
while(1)
{
n += response.documents().size();
if ( response.cursorID() == 0 )
break;
response = cursor.next(*_mongo);
}
assert(n == 10000);
Poco::MongoDB::QueryRequest drop("team.$cmd");
drop.setNumberToReturn(1);
drop.selector().add("drop", std::string("numbers"));
Poco::MongoDB::ResponseMessage responseDrop;
_mongo->sendRequest(drop, responseDrop);
}
示例2: getLastErrorDoc
Poco::MongoDB::Document::Ptr Database::ensureIndex(Connection& connection, const std::string& collection, const std::string& indexName, Poco::MongoDB::Document::Ptr keys, bool unique, bool background, int version, int ttl)
{
Poco::MongoDB::Document::Ptr index = new Poco::MongoDB::Document();
index->add("ns", _dbname + ".players");
index->add("name", indexName);
index->add("key", keys);
if ( version > 0 )
{
index->add("version", version);
}
if ( unique )
{
index->add("unique", true);
}
if ( background )
{
index->add("background", true);
}
if ( ttl > 0 )
{
index->add("expireAfterSeconds", ttl);
}
Poco::SharedPtr<Poco::MongoDB::InsertRequest> insertRequest = createInsertRequest("system.indexes");
insertRequest->documents().push_back(index);
connection.sendRequest(*insertRequest);
insertRequest->documents().push_back(index);
connection.sendRequest(*insertRequest);
return getLastErrorDoc(connection);
}
示例3: testCursorRequest
void MongoDBTest::testCursorRequest()
{
if (!_connected)
{
std::cout << "Not connected, test skipped." << std::endl;
return;
}
Poco::MongoDB::Database db("team");
Poco::SharedPtr<Poco::MongoDB::InsertRequest> insertRequest = db.createInsertRequest("numbers");
for(int i = 0; i < 10000; ++i)
{
Document::Ptr doc = new Document();
doc->add("number", i);
insertRequest->documents().push_back(doc);
}
_mongo.sendRequest(*insertRequest);
double count = db.count(_mongo, "numbers");
assert(count == 10000);
Poco::MongoDB::Cursor cursor("team", "numbers");
int n = 0;
Poco::MongoDB::ResponseMessage& response = cursor.next(_mongo);
while(1)
{
n += response.documents().size();
if ( response.cursorID() == 0 )
break;
response = cursor.next(_mongo);
}
std::cout << "n= " << n << std::endl;
assert(n == 10000);
Poco::MongoDB::QueryRequest drop("team.$cmd");
drop.setNumberToReturn(1);
drop.selector().add("drop", std::string("numbers"));
Poco::MongoDB::ResponseMessage responseDrop;
_mongo.sendRequest(drop, responseDrop);
if ( responseDrop.documents().size() > 0 )
{
std::cout << responseDrop.documents()[0]->toString(2) << std::endl;
}
}
示例4: sample1
//.........这里部分代码省略.........
.add("firstname", "Marc")
.add("birthyear", 1991);
insertPlayerRequest->addNewDocument()
.add("lastname", "Alba")
.add("firstname", "Jordi")
.add("birthyear", 1989);
insertPlayerRequest->addNewDocument()
.add("lastname", "Montoya")
.add("firstname", "Martin")
.add("birthyear", 1991);
insertPlayerRequest->addNewDocument()
.add("lastname", "Abidal")
.add("firstname", "Eric")
.add("birthyear", 1979);
insertPlayerRequest->addNewDocument()
.add("lastname", "Fontas")
.add("firstname", "Andreu")
.add("birthyear", 1989);
insertPlayerRequest->addNewDocument()
.add("lastname", "Messi")
.add("firstname", "Lionel")
.add("birthyear", 1987);
insertPlayerRequest->addNewDocument()
.add("lastname", "Puyol")
.add("firstname", "Carles")
.add("birthyear", 1978);
insertPlayerRequest->addNewDocument()
.add("lastname", "Piqué")
.add("firstname", "Gerard")
.add("birthyear", 1987);
insertPlayerRequest->addNewDocument()
.add("lastname", "Muniesa")
.add("firstname", "Marc")
.add("birthyear", 1992);
insertPlayerRequest->addNewDocument()
.add("lastname", "Fabrégas")
.add("firstname", "Cesc")
.add("birthyear", 1987);
insertPlayerRequest->addNewDocument()
.add("lastname", "Hernandez")
.add("firstname", "Xavi")
.add("birthyear", 1980);
insertPlayerRequest->addNewDocument()
.add("lastname", "Iniesta")
.add("firstname", "Andres")
.add("birthyear", 1984);
insertPlayerRequest->addNewDocument()
.add("lastname", "Alcantara")
.add("firstname", "Thiago")
.add("birthyear", 1991);
insertPlayerRequest->addNewDocument()
.add("lastname", "Dos Santos")
.add("firstname", "Jonathan")
.add("birthyear", 1990);
insertPlayerRequest->addNewDocument()
.add("lastname", "Mascherano")
.add("firstname", "Javier")
.add("birthyear", 1984);
insertPlayerRequest->addNewDocument()
.add("lastname", "Busquets")
.add("firstname", "Sergio")
.add("birthyear", 1988);
insertPlayerRequest->addNewDocument()
.add("lastname", "Adriano")
.add("firstname", "")
.add("birthyear", 1984);
insertPlayerRequest->addNewDocument()
.add("lastname", "Song")
.add("firstname", "Alex")
.add("birthyear", 1987);
insertPlayerRequest->addNewDocument()
.add("lastname", "Villa")
.add("firstname", "David")
.add("birthyear", 1981);
insertPlayerRequest->addNewDocument()
.add("lastname", "Sanchez")
.add("firstname", "Alexis")
.add("birthyear", 1988);
insertPlayerRequest->addNewDocument()
.add("lastname", "Pedro")
.add("firstname", "")
.add("birthyear", 1987);
insertPlayerRequest->addNewDocument()
.add("lastname", "Cuenca")
.add("firstname", "Isaac")
.add("birthyear", 1991);
insertPlayerRequest->addNewDocument()
.add("lastname", "Tello")
.add("firstname", "Cristian")
.add("birthyear", 1991);
std::cout << insertPlayerRequest->documents().size() << std::endl;
connection.sendRequest(*insertPlayerRequest);
std::string lastError = db.getLastError(connection);
if ( !lastError.empty() )
{
std::cout << "Last Error: " << db.getLastError(connection) << std::endl;
}
}