1
0
mirror of https://github.com/stefanocasazza/ULib.git synced 2025-09-28 19:05:55 +08:00
ULib/tests/ulib/test_mongodb.cpp
stefanocasazza 5c1a3c49ea sync
2016-10-06 16:09:35 +02:00

28 lines
654 B
C++

// test_mongodb.cpp
#include <ulib/net/client/mongodb.h>
int
U_EXPORT main(int argc, char* argv[])
{
U_ULIB_INIT(argv);
U_TRACE(5,"main(%d)",argc)
UMongoDBClient x;
const char* name_collection = argv[1];
const char* json = argv[2];
if (x.connect(0,0) &&
x.selectCollection("hello_world", name_collection))
{
if (U_STREQ(name_collection, strlen(name_collection), "Fortune")) (void) x.findAll();
else
{
if (json) (void) x.findOne(json, strlen(json));
(void) x.findOne(8980);
(void) x.update(8980, "randomNumber", 8980);
}
}
}