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

[CDRIVER-5662] Tutorials for simple CRUD, and some more convience APIs #6

Merged
merged 15 commits into from
Jan 30, 2025

Conversation

vector-of-bool
Copy link
Collaborator

Summary

Refer: CDRIVER-5662

Reviewing this changeset per-commit is recommended.

This changeset adds two tutorials for the basics of reading and writing data from a database. More complex CRUD operation tutorials could be written, or may be better as how-tos, but those are not included or scheduled here.

These changes also introduce a few convenience APIs and tweak the way status message are obtained.

Changes (chronological)

  • 735e64f Messages on amongoc_status are now non-allocating. This is based on the newer Boost.System design which allows the caller to provide a scratch space in which the API may write a C string.
  • 8893234 Adds convenience overloads of amongoc_tie, allowing the caller to tie only the status, only the result, or omit the allocator.
  • 1a7996b Convenience overloads for amongoc_insert_one.
  • cc382c9 Default loop init might fail, so set it nodiscard
  • b8fb225 Adds a convenience macro for checking the error and getting the message from an amongoc_status
  • 25d0d3d Adds the "insert some data" tutorial
  • be8ae4c Adds a "how to use amongoc_status" page.
  • efd22da Big detour: I wanted a give users an easy way to write the output of BSON data in a human-readable form. This commit adds an abstraction for char output, leading into:
  • d1d1a32 A function that can format a BSON document into an arbitrary output stream. This is based on the internal tracing output, but now publicly visible. The output format is very simple and not meant to be portable, just for human consumption.
  • 9f812e1 Modifies the "communicate" sample to use the new printer, simplifying the example code.
  • 75a8cfa Adds the "read the content of a collection" tutorial.

Copy link
Collaborator

@kevinAlbs kevinAlbs 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 minor comments. I found the read/write tutorials easy to follow with the annotated examples. I like the new amongoc_if_error macro.

docs/ref/status.rst Outdated Show resolved Hide resolved
docs/ref/status.rst Outdated Show resolved Hide resolved
src/bson/format.cpp Outdated Show resolved Hide resolved
docs/how-to/communicate.example.c Outdated Show resolved Hide resolved
docs/learn/read.rst Outdated Show resolved Hide resolved
Co-authored-by: Kevin Albertson <kevin.albertson@mongodb.com>
@vector-of-bool vector-of-bool merged commit 52736e0 into develop Jan 30, 2025
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.

2 participants