-
Notifications
You must be signed in to change notification settings - Fork 0
/
mongo.h
49 lines (31 loc) · 1.11 KB
/
mongo.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef MONGO_H
#define MONGO_H
#include "database.h"
#include <mongo/client/dbclient.h>
#include <bson/bson.h>
#include <vector>
using namespace mongo;
class Mongo : public Database
{
public:
static Mongo* get_instance();
void release();
bool is_ok();
virtual bool connect( string db = "localhost");
void select_db( string db);
void select_collection( string col);
bool write( BSONObj obj, string collection = "", string db = "");
void read( vector<BSONObj>& results, BSONObj obj = BSONObj(), string collection = "", string db = "");
BSONObj read_one(BSONObj obj = BSONObj(), string collection = "", string db = "");
size_t count(string collection = "", string db = "");
void delete_all(string collection = "", string db = "");
private:
Mongo();
~Mongo();
static Mongo* m_instance;
bool m_init;
DBClientConnection m_conn;
string m_db;
string m_col;
};
#endif // MONGO_H