File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,11 @@ include_directories(
6
6
7
7
set (MONGOCXX_EXAMPLES
8
8
aggregate.cpp
9
+ create.cpp
10
+ index.cpp
9
11
query.cpp
10
12
remove .cpp
11
13
update.cpp
12
- create.cpp
13
14
)
14
15
15
16
foreach (EXAMPLE_SRC ${MONGOCXX_EXAMPLES} )
Original file line number Diff line number Diff line change
1
+ #include < bsoncxx/builder.hpp>
2
+
3
+ #include < mongocxx/client.hpp>
4
+
5
+ using namespace bsoncxx ::builder::helpers;
6
+ using bsoncxx::builder::document;
7
+
8
+ int main (int , char **) {
9
+ mongocxx::client conn{};
10
+
11
+ auto db = conn[" test" ];
12
+
13
+ // Create a single field index.
14
+ {
15
+ // @begin: cpp-single-field-index
16
+ document index_spec;
17
+ index_spec << " cuisine" << 1 ;
18
+ db[" restaurants" ].create_index (index_spec, {});
19
+ // @end: cpp-single-field-index
20
+ }
21
+
22
+ // Create a compound index.
23
+ {
24
+ // @begin: cpp-create-compound-index
25
+ document index_spec;
26
+ index_spec << " cuisine" << 1 << " address.zipcode" << -1 ;
27
+ db[" restaurants" ].create_index (index_spec, {});
28
+ // @end: cpp-create-compound-index
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments