Skip to content

Commit cc3ed2c

Browse files
CDRIVER-4363 document mongoc_bulkwrite_t (#1602)
* document `mongoc_bulkwrite_t` * rename `set_hint_opt` to `set_bson_value_opt` To reuse for the `comment` option * use `bson_value_t` for `comment`, not `bson_t` Matches the spec, and existing C driver representation of `comment` for other functions. --------- Co-authored-by: Roberto C. Sánchez <[email protected]>
1 parent a8513a2 commit cc3ed2c

File tree

81 files changed

+1548
-20
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1548
-20
lines changed

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ documentation to be generated:
127127
./tools/poetry.sh run sphinx-build -WEn -bhtml src/libmongoc/doc/ src/libmongoc/doc/html
128128
```
129129

130+
`sphinx-autobuild` can be used to serve docs locally. This can be convenient when editing. Files are rebuilt
131+
when changes are detected:
132+
133+
```sh
134+
./tools/poetry.sh run sphinx-autobuild -b html src/libmongoc/doc/ src/libmongoc/doc/html --re-ignore ".*.pickle" --re-ignore ".*.doctree" -j auto
135+
```
130136

131137
### Testing
132138

src/libmongoc/doc/api.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ API Reference
1111
lifecycle
1212
gridfs
1313
mongoc_auto_encryption_opts_t
14+
mongoc_bulkwrite_t
15+
mongoc_bulkwriteopts_t
16+
mongoc_bulkwriteresult_t
17+
mongoc_bulkwriteexception_t
1418
mongoc_bulk_operation_t
1519
mongoc_change_stream_t
1620
mongoc_client_encryption_t
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
If using MongoDB server 8.0+, prefer :symbol:`mongoc_bulkwrite_t` over :symbol:`mongoc_bulk_operation_t` to reduce
2+
network round trips.
3+
4+
:symbol:`mongoc_bulkwrite_t` uses the ``bulkWrite`` server command introduced in MongoDB server 8.0. ``bulkWrite``
5+
command supports insert, update, and delete operations in the same payload. ``bulkWrite`` supports use of multiple
6+
collection namespaces in the same payload.
7+
8+
:symbol:`mongoc_bulk_operation_t` uses the ``insert``, ``update`` and ``delete`` server commands available in all
9+
current MongoDB server versions. Write operations are grouped by type (insert, update, delete) and sent in separate
10+
commands. Only one collection may be specified per bulk write.

src/libmongoc/doc/mongoc_bulk_operation_t.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ Synopsis
1212
1313
typedef struct _mongoc_bulk_operation_t mongoc_bulk_operation_t;
1414
15-
The opaque type ``mongoc_bulk_operation_t`` provides an abstraction for submitting multiple write operations as a single batch.
15+
Description
16+
-----------
1617

17-
After adding all of the write operations to the ``mongoc_bulk_operation_t``, call :symbol:`mongoc_bulk_operation_execute()` to execute the operation.
18+
:symbol:`mongoc_bulk_operation_t` provides an abstraction for submitting multiple write operations as a single batch.
19+
20+
After adding all of the write operations to the :symbol:`mongoc_bulk_operation_t`, call
21+
:symbol:`mongoc_bulk_operation_execute()` to execute the operation.
1822

1923
.. warning::
2024

@@ -23,6 +27,11 @@ After adding all of the write operations to the ``mongoc_bulk_operation_t``, cal
2327
.. seealso::
2428

2529
| `Bulk Write Operations <bulk_>`_
30+
| :symbol:`mongoc_bulkwrite_t`
31+
32+
.. note::
33+
34+
.. include:: includes/bulkwrite-vs-bulk_operation.txt
2635

2736
.. only:: html
2837

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
:man_page: mongoc_bulkwrite_append_deletemany
2+
3+
mongoc_bulkwrite_append_deletemany()
4+
====================================
5+
6+
Synopsis
7+
--------
8+
9+
.. code-block:: c
10+
11+
bool
12+
mongoc_bulkwrite_append_deletemany (mongoc_bulkwrite_t *self,
13+
const char *ns,
14+
const bson_t *filter,
15+
const mongoc_bulkwrite_deletemanyopts_t *opts /* May be NULL */,
16+
bson_error_t *error);
17+
18+
Description
19+
-----------
20+
21+
Adds a multi-document delete into the namespace ``ns``. Returns true on success. Returns false and sets ``error`` if an
22+
error occured.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
:man_page: mongoc_bulkwrite_append_deleteone
2+
3+
mongoc_bulkwrite_append_deleteone()
4+
===================================
5+
6+
Synopsis
7+
--------
8+
9+
.. code-block:: c
10+
11+
bool
12+
mongoc_bulkwrite_append_deleteone (mongoc_bulkwrite_t *self,
13+
const char *ns,
14+
const bson_t *filter,
15+
const mongoc_bulkwrite_deleteoneopts_t *opts /* May be NULL */,
16+
bson_error_t *error);
17+
18+
Description
19+
-----------
20+
21+
Adds a single-document delete into the namespace ``ns``. Returns true on success. Returns false and sets ``error`` if an
22+
error occured.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
:man_page: mongoc_bulkwrite_append_insertone
2+
3+
mongoc_bulkwrite_append_insertone()
4+
===================================
5+
6+
Synopsis
7+
--------
8+
9+
.. code-block:: c
10+
11+
bool
12+
mongoc_bulkwrite_append_insertone (mongoc_bulkwrite_t *self,
13+
const char *ns,
14+
const bson_t *document,
15+
const mongoc_bulkwrite_insertoneopts_t *opts /* May be NULL */,
16+
bson_error_t *error);
17+
18+
Description
19+
-----------
20+
21+
Adds a document to insert into the namespace ``ns``. Returns true on success. Returns false and sets ``error`` if an
22+
error occured.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
:man_page: mongoc_bulkwrite_append_replaceone
2+
3+
mongoc_bulkwrite_append_replaceone()
4+
====================================
5+
6+
Synopsis
7+
--------
8+
9+
.. code-block:: c
10+
11+
bool
12+
mongoc_bulkwrite_append_replaceone (mongoc_bulkwrite_t *self,
13+
const char *ns,
14+
const bson_t *filter,
15+
const bson_t *replacement,
16+
const mongoc_bulkwrite_replaceoneopts_t *opts /* May be NULL */,
17+
bson_error_t *error);
18+
19+
Description
20+
-----------
21+
22+
Adds a replace operation for the namespace ``ns``. Returns true on success. Returns false and sets ``error`` if an
23+
error occured.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
:man_page: mongoc_bulkwrite_append_updatemany
2+
3+
mongoc_bulkwrite_append_updatemany()
4+
====================================
5+
6+
Synopsis
7+
--------
8+
9+
.. code-block:: c
10+
11+
bool
12+
mongoc_bulkwrite_append_updatemany (mongoc_bulkwrite_t *self,
13+
const char *ns,
14+
const bson_t *filter,
15+
const bson_t *update,
16+
const mongoc_bulkwrite_updatemanyopts_t *opts /* May be NULL */,
17+
bson_error_t *error);
18+
19+
Description
20+
-----------
21+
22+
Adds a multi-document update for the namespace ``ns``. Returns true on success. Returns false and sets ``error`` if an
23+
error occured.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
:man_page: mongoc_bulkwrite_append_updateone
2+
3+
mongoc_bulkwrite_append_updateone()
4+
===================================
5+
6+
Synopsis
7+
--------
8+
9+
.. code-block:: c
10+
11+
bool
12+
mongoc_bulkwrite_append_updateone (mongoc_bulkwrite_t *self,
13+
const char *ns,
14+
const bson_t *filter,
15+
const bson_t *update,
16+
const mongoc_bulkwrite_updateoneopts_t *opts /* May be NULL */,
17+
bson_error_t *error);
18+
19+
Description
20+
-----------
21+
22+
Adds a single-document update for the namespace ``ns``. Returns true on success. Returns false and sets ``error`` if an
23+
error occured.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
:man_page: mongoc_bulkwrite_deletemanyopts_destroy
2+
3+
mongoc_bulkwrite_deletemanyopts_destroy()
4+
=========================================
5+
6+
Synopsis
7+
--------
8+
9+
.. code-block:: c
10+
11+
void
12+
mongoc_bulkwrite_deletemanyopts_destroy (mongoc_bulkwrite_deletemanyopts_t *self);
13+
14+
Description
15+
-----------
16+
17+
Frees a :symbol:`mongoc_bulkwrite_deletemanyopts_t`.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
:man_page: mongoc_bulkwrite_deletemanyopts_new
2+
3+
mongoc_bulkwrite_deletemanyopts_new()
4+
=====================================
5+
6+
Synopsis
7+
--------
8+
9+
.. code-block:: c
10+
11+
mongoc_bulkwrite_deletemanyopts_t *
12+
mongoc_bulkwrite_deletemanyopts_new (void);
13+
14+
Description
15+
-----------
16+
17+
Returns a new :symbol:`mongoc_bulkwrite_deletemanyopts_new`.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
:man_page: mongoc_bulkwrite_deletemanyopts_set_collation
2+
3+
mongoc_bulkwrite_deletemanyopts_set_collation()
4+
===============================================
5+
6+
Synopsis
7+
--------
8+
9+
.. code-block:: c
10+
11+
void
12+
mongoc_bulkwrite_deletemanyopts_set_collation (mongoc_bulkwrite_deletemanyopts_t *self, const bson_t *collation);
13+
14+
Description
15+
-----------
16+
17+
Specifies a collation.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
:man_page: mongoc_bulkwrite_deletemanyopts_set_hint
2+
3+
mongoc_bulkwrite_deletemanyopts_set_hint()
4+
==========================================
5+
6+
Synopsis
7+
--------
8+
9+
.. code-block:: c
10+
11+
void
12+
mongoc_bulkwrite_deletemanyopts_set_hint (mongoc_bulkwrite_deletemanyopts_t *self, const bson_value_t *hint);
13+
14+
Description
15+
-----------
16+
17+
Specifies the index to use. Specify either the index name as a string or the index key pattern. If specified, then the
18+
query system will only consider plans using the hinted index.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
:man_page: mongoc_bulkwrite_deletemanyopts_t
2+
3+
mongoc_bulkwrite_deletemanyopts_t
4+
=================================
5+
6+
Synopsis
7+
--------
8+
9+
.. code-block:: c
10+
11+
typedef struct _mongoc_bulkwrite_deletemanyopts_t mongoc_bulkwrite_deletemanyopts_t;
12+
13+
.. only:: html
14+
15+
Functions
16+
---------
17+
18+
.. toctree::
19+
:titlesonly:
20+
:maxdepth: 1
21+
22+
mongoc_bulkwrite_deletemanyopts_new
23+
mongoc_bulkwrite_deletemanyopts_destroy
24+
mongoc_bulkwrite_deletemanyopts_set_collation
25+
mongoc_bulkwrite_deletemanyopts_set_hint
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
:man_page: mongoc_bulkwrite_deleteoneopts_destroy
2+
3+
mongoc_bulkwrite_deleteoneopts_destroy()
4+
========================================
5+
6+
Synopsis
7+
--------
8+
9+
.. code-block:: c
10+
11+
void
12+
mongoc_bulkwrite_deleteoneopts_destroy (mongoc_bulkwrite_deleteoneopts_t *self);
13+
14+
Description
15+
-----------
16+
17+
Frees a :symbol:`mongoc_bulkwrite_deleteoneopts_t`.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
:man_page: mongoc_bulkwrite_deleteoneopts_new
2+
3+
mongoc_bulkwrite_deleteoneopts_new()
4+
====================================
5+
6+
Synopsis
7+
--------
8+
9+
.. code-block:: c
10+
11+
mongoc_bulkwrite_deleteoneopts_t *
12+
mongoc_bulkwrite_deleteoneopts_new (void);
13+
14+
Description
15+
-----------
16+
17+
Returns a new :symbol:`mongoc_bulkwrite_deleteoneopts_t`.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
:man_page: mongoc_bulkwrite_deleteoneopts_set_collation
2+
3+
mongoc_bulkwrite_deleteoneopts_set_collation()
4+
==============================================
5+
6+
Synopsis
7+
--------
8+
9+
.. code-block:: c
10+
11+
void
12+
mongoc_bulkwrite_deleteoneopts_set_collation (mongoc_bulkwrite_deleteoneopts_t *self, const bson_t *collation);
13+
14+
Description
15+
-----------
16+
17+
Specifies a collation.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
:man_page: mongoc_bulkwrite_deleteoneopts_set_hint
2+
3+
mongoc_bulkwrite_deleteoneopts_set_hint()
4+
=========================================
5+
6+
Synopsis
7+
--------
8+
9+
.. code-block:: c
10+
11+
void
12+
mongoc_bulkwrite_deleteoneopts_set_hint (mongoc_bulkwrite_deleteoneopts_t *self, const bson_value_t *hint);
13+
14+
Description
15+
-----------
16+
17+
Specifies the index to use. Specify either the index name as a string or the index key pattern. If specified, then the
18+
query system will only consider plans using the hinted index.

0 commit comments

Comments
 (0)