You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorial/markdown/c++/cxx-quickstart.md
+14-11Lines changed: 14 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -100,9 +100,10 @@ This will download and install all the dependencies required for the project to
100
100
At this point, we have installed the dependencies, loaded the travel-sample data and configured the application with the credentials. The application is now ready and you can run it by executing the following command from the build directory:
101
101
102
102
```sh
103
+
cmake --build .
103
104
./cxx_quickstart
104
105
```
105
-
106
+
> Note: Run this command from the build directory
106
107
107
108
### Verifying the Application
108
109
@@ -229,15 +230,12 @@ auto res = Delete(col, doc_id);
229
230
### Query
230
231
We can use the `Query` function to execute any N1QL (SQL++) query on a scope.
231
232
- Executes the N1QL query using the provided `scope.query(query, opts)`.
232
-
- Returns the result of the query if successful. The result is returned as a `couchbase::query_results` object.
233
+
- Returns the result of the query if successful. The result is added to a `std::vector<std::string>` object that contains the `id, country, avg_rating, title`.
233
234
- We can pass `opts` parameter, which can be used to insert positonal parameters in the query.
234
235
- If there is an error, it prints an error message and returns an empty result object.
235
236
236
237
```c++
237
238
//operations.cpp
238
-
auto [q_err, q_res] = scope.query(query, opts).get();
239
-
240
-
//main.cpp
241
239
std::string query{ R"(
242
240
SELECT META(h).id, h AS doc,
243
241
AVG(r.ratings.Overall) AS avg_rating
@@ -248,12 +246,13 @@ std::string query{ R"(
248
246
ORDER BY avg_rating DESC
249
247
LIMIT 5;
250
248
)" };
249
+
auto [q_err, q_res] = scope.query(query, couchbase::query_options{}.positional_parameters(std::vector<std::string>{"United States", "United Kingdom"})).get();
251
250
252
-
auto query_res = Query(scope, query, couchbase::query_options{}.positional_parameters(std::vector<std::string>{"United States", "United Kingdom"}));
0 commit comments