Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CXX-2582 revise tutorial #940

Merged
merged 31 commits into from
Mar 13, 2023
Merged

CXX-2582 revise tutorial #940

merged 31 commits into from
Mar 13, 2023

Conversation

kevinAlbs
Copy link
Collaborator

@kevinAlbs kevinAlbs commented Mar 9, 2023

Summary

  • Add tutorial.cpp with code snippets from tutorial.md.
  • Satisfy requests from CXX-2582
    • e1f0d6e add an example of getting inserted IDs.
    • c33534f renames coll to collection.
    • 9d28594 distinguishes result variables to make examples easier to copy-paste.
  • Make several changes to tutorial.cpp. Notably:
    • 69f1e75 fixes a compile error.
    • 40113e6 simplifies the examples to use only three documents.
    • 60da85a replaces prints with assertions.
  • Apply updates from tutorial.cpp to tutorial.md.

Background & Motivation

Adding tutorial.cpp with assertions is intended to make it easier to verify correctness of tutorial code snippets.

Changes were applied to tutorial.cpp in separate commits. Commit messages describe some of the rationale.

Documentation can be built locally with cmake --build cmake-build --target hugo and viewed with open ./build/hugo/mongocxx-v3/tutorial/index.html.

Evergreen appears to not be receiving GitHub checks at the moment. Here is an Evergreen patch build with these changes.

kevinAlbs added 30 commits March 9, 2023 09:00
CXX-894 is resolved
It is not output by pkg-config for libmongocxx and is not necessary for an application
The invalid JSON values are rendered highlighted in black.
Fixes `error: no member named 'to_string' in 'std::string_view'`
This is requested in the ticket.
Use of the stream builder is documented as discouraged.
The basic builder syntax is more succinct.
To shorten the output
To fix `-Wunused-variable` warnings
This is the default behavior unless overridden with an unacknowledged write concern.
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
To further simplify example.
Release builds may undefine the assert macro and result
in -Wunused-variable warnings.
@kevinAlbs kevinAlbs marked this pull request as ready for review March 9, 2023 16:59
Copy link
Contributor

@kkloberdanz kkloberdanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@rcsanchez97 rcsanchez97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with one minor typo fix.

docs/content/mongocxx-v3/tutorial.md Outdated Show resolved Hide resolved
Co-authored-by: Roberto C. Sánchez <roberto@connexer.com>
@kevinAlbs kevinAlbs merged commit 6af37f8 into mongodb:master Mar 13, 2023
kevinAlbs added a commit that referenced this pull request Mar 13, 2023
* 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 <roberto@connexer.com>

---------

Co-authored-by: Roberto C. Sánchez <roberto@connexer.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants