Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1.     if (db.connect("devmoon.se"))
  2.     {
  3.         // add entry
  4.         NestDB::Document entry;
  5.         entry["name"] = "foo";
  6.         entry["someVariable"] = 1337;
  7.  
  8.         db.add("nest.accounts", entry);
  9.  
  10.  
  11.         // find entries where name = krisse
  12.         NestDB::Document search;
  13.         search["name"] = "krisse";
  14.  
  15.         NestDB::Result result = db.find("nest.accounts", search);
  16.  
  17.         // go trough the results
  18.         while (result.next())
  19.         {
  20.             NestDB::Document doc(result);
  21.  
  22.             std::string id = doc["_id"]["$oid"].asString();
  23.             std::string name = doc["name"].asString();
  24.  
  25.             std::cout << id << " " << name << std::endl;
  26.         }
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement