]> git.jsancho.org Git - bongodb.git/blob - src/bongodb.h
Basic searching support
[bongodb.git] / src / bongodb.h
1 /*
2  * BongoDB, an embedded document-based engine
3  * Copyright (C) 2015 by Javier Sancho Fernandez <jsf at jsancho dot org>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #ifndef __BONGODB_H_
20 #define __BONGODB_H_
21
22
23 /* BongoDB Client */
24
25 typedef struct {
26   char *key;
27   char *value;
28   struct bongo_record_tag_t *next;
29 } bongo_record_tag_t;
30
31 typedef struct {
32   bongo_record_tag_t *tags;
33   struct bongo_record_node_t *next;
34 } bongo_record_node_t;
35
36 typedef struct {
37   const char *col_name;
38   int n_records;
39   bongo_record_node_t *records;
40   struct bongo_collection_node_t *next;
41 } bongo_collection_node_t;
42
43 typedef struct {
44   const char *db_name;
45   int n_collections;
46   bongo_collection_node_t *collections;
47   struct bongo_database_node_t *next;
48 } bongo_database_node_t;
49
50 typedef struct {
51   int n_databases;
52   bongo_database_node_t *databases;
53 } bongo_client_t;
54
55 bongo_client_t *
56 bongo_client_new (void);
57
58 bongo_database_node_t *
59 bongo_database_node_new (bongo_client_t *client,
60                          const char *db_name);
61
62 bongo_collection_node_t *
63 bongo_collection_node_new (bongo_database_node_t *database_node,
64                            const char *col_name);
65
66 bongo_database_node_t *
67 bongo_database_node_search (bongo_client_t *client,
68                             const char *db_name);
69
70 bongo_collection_node_t *
71 bongo_collection_node_search (bongo_database_node_t *database_node,
72                               const char *col_name);
73
74 void
75 bongo_collection_node_destroy (bongo_collection_node_t *collection_node);
76
77 void
78 bongo_database_node_destroy (bongo_database_node_t *database_node);
79
80 void
81 bongo_client_destroy (bongo_client_t *client);
82
83
84 /* BongoDB Database */
85
86 typedef struct {
87   bongo_database_node_t *database_node;
88 } bongo_database_t;
89
90 bongo_database_t *
91 bongo_client_get_database (bongo_client_t *client,
92                            const char *db_name);
93
94 void
95 bongo_database_destroy (bongo_database_t *database);
96
97
98 /* BongoDB Collection */
99
100 typedef struct {
101   bongo_collection_node_t *collection_node;
102 } bongo_collection_t;
103
104 bongo_collection_t *
105 bongo_client_get_collection (bongo_client_t *client,
106                              const char *db_name,
107                              const char *col_name);
108
109 bool
110 bongo_collection_insert (bongo_collection_t *collection,
111                          bongo_insert_flags_t flags,
112                          const char *document,
113                          const bongo_write_concern_t *write_concern,
114                          bongo_error_t *error);
115
116 void
117 bongo_collection_destroy (bongo_collection_t *collection);
118
119
120 #endif /* __BONGODB_H_ */