Skip to content

Commit

Permalink
CXX-2582 revise tutorial (#940)
Browse files Browse the repository at this point in the history
* remove outdated comment

CXX-894 is resolved

* remove libmongoc and libbson include headers

It is not output by pkg-config for libmongocxx and is not necessary for an application

* fix rendering of invalid JSON

The invalid JSON values are rendered highlighted in black.

* add initial tutorial

* rename `coll` to `collection`

* use `collection`, not `restaurants`

* use `string_view`, not `string`

Fixes `error: no member named 'to_string' in 'std::string_view'`

* use `view`, not `doc`

* use `auto`

* distinguish result variables

* show example of getting insert ids

This is requested in the ticket.

* add scopes and comments

* use inline document

* replace stream builder with basic builder

Use of the stream builder is documented as discouraged.
The basic builder syntax is more succinct.

* make less documents

To shorten the output

* drop collection to clean up

* rename `view` to `doc_view`

* add assertions on unused variables

To fix `-Wunused-variable` warnings

* assert writes return results

This is the default behavior unless overridden with an unacknowledged write concern.

* update "versions" array to reflect supported versions

C++ driver 3.7.0 depends on C driver 1.22.1.
C driver 1.22.1 supports MongoDB versions 3.6+.
The docs compatibility table here is incorrect: https://www.mongodb.com/docs/drivers/cxx/#mongodb-compatibility

* fix assert

* use only three documents in tutorial

To further simplify example.

* use assert instead of printing

* add example of printing all documents

* remove TODO comment

* remove whitespace

* note requirement of get_utf8 in C++ driver < 3.7.0

* apply changes to tutorial.md

* fix assert define check

* move redefinition of `assert` macro

Release builds may undefine the assert macro and result
in -Wunused-variable warnings.

* Update docs/content/mongocxx-v3/tutorial.md

Co-authored-by: Roberto C. Sánchez <[email protected]>

---------

Co-authored-by: Roberto C. Sánchez <[email protected]>
  • Loading branch information
kevinAlbs and rcsanchez97 committed Mar 13, 2023
1 parent c2e6eb4 commit a94ee66
Show file tree
Hide file tree
Showing 4 changed files with 291 additions and 119 deletions.
Loading

0 comments on commit a94ee66

Please sign in to comment.