Skip to content

Commit 1600808

Browse files
committed
CDRIVER-2643 update docs for new GridFS impl
1 parent 9d16c1a commit 1600808

File tree

5 files changed

+41
-2
lines changed

5 files changed

+41
-2
lines changed

src/libmongoc/doc/api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ API Reference
99
logging
1010
errors
1111
lifecycle
12+
gridfs
1213
mongoc_bulk_operation_t
1314
mongoc_change_stream_t
1415
mongoc_client_pool_t

src/libmongoc/doc/gridfs.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
GridFS
2+
======
3+
4+
The C driver includes two APIs for GridFS.
5+
6+
The older API consists of :symbol:`mongoc_gridfs_t` and its derivatives. It contains deprecated API, does not support read preferences, and is not recommended in new applications. It does not conform to the `MongoDB GridFS specification <https://github.com/mongodb/specifications/blob/master/source/gridfs/gridfs-spec.rst>`_.
7+
8+
The newer API consists of :symbol:`mongoc_gridfs_bucket_t` and allows uploading/downloading through derived :symbol:`mongoc_stream_t` objects. It conforms to the `MongoDB GridFS specification <https://github.com/mongodb/specifications/blob/master/source/gridfs/gridfs-spec.rst>`_.
9+
10+
There is not always a straightforward upgrade path from an application built with :symbol:`mongoc_gridfs_t` to :symbol:`mongoc_gridfs_bucket_t` (e.g. a :symbol:`mongoc_gridfs_file_t` provides functions to seek but :symbol:`mongoc_stream_t` does not). But users are encouraged to upgrade when possible.

src/libmongoc/doc/lifecycle.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ You can create a :symbol:`mongoc_gridfs_t` from a :symbol:`mongoc_client_t`, cre
2626

2727
Each of these objects depends on the object it was created from. Always destroy GridFS objects in the reverse of the order they were created. The sole exception is that a :symbol:`mongoc_gridfs_file_t` need not be destroyed before the :symbol:`mongoc_gridfs_file_list_t` it was created from.
2828

29+
GridFS bucket objects
30+
---------------------
31+
32+
Create :symbol:`mongoc_gridfs_bucket_t` with a :symbol:`mongoc_database_t` derived from a :symbol:`mongoc_client_t`. The :symbol:`mongoc_database_t` is independent from the :symbol:`mongoc_gridfs_bucket_t`. But the :symbol:`mongoc_client_t` must outlive the :symbol:`mongoc_gridfs_bucket_t`.
33+
34+
A :symbol:`mongoc_stream_t` may be created from the :symbol:`mongoc_gridfs_bucket_t`. The :symbol:`mongoc_gridfs_bucket_t` must outlive the :symbol:`mongoc_stream_t`.
35+
2936
Sessions
3037
--------
3138

src/libmongoc/doc/mongoc_gridfs_bucket_t.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ Synopsis
1515
Description
1616
-----------
1717

18-
``mongoc_gridfs_bucket_t`` provides a MongoDB GridFS implementation, superseding :symbol:`mongoc_gridfs_t`. See the `GridFS MongoDB documentation <https://docs.mongodb.com/manual/core/gridfs/>`_.
18+
``mongoc_gridfs_bucket_t`` provides a spec-compliant MongoDB GridFS implementation, superseding :symbol:`mongoc_gridfs_t`. See the `GridFS MongoDB documentation <https://docs.mongodb.com/manual/core/gridfs/>`_.
1919

2020
Thread Safety
2121
-------------
2222

23-
``mongoc_gridfs_bucket_t`` is NOT thread-safe and should only be used in the same thread as the owning :symbol:`mongoc_client_t`.
23+
:symbol:`mongoc_gridfs_bucket_t` is NOT thread-safe and should only be used in the same thread as the owning :symbol:`mongoc_client_t`.
24+
25+
Lifecycle
26+
---------
27+
28+
It is an error to free a :symbol:`mongoc_gridfs_bucket_t` before freeing all derived instances of :symbol:`mongoc_stream_t`. The owning :symbol:`mongoc_client_t` must outlive the :symbol:`mongoc_gridfs_bucket_t`.
29+
2430

2531
Example
2632
-------
@@ -29,6 +35,11 @@ Example
2935
:language: c
3036
:caption: example-gridfs-bucket.c
3137

38+
See also
39+
--------
40+
41+
- The `MongoDB GridFS specification <https://github.com/mongodb/specifications/blob/master/source/gridfs/gridfs-spec.rst>`_.
42+
- The non spec-compliant :symbol:`mongoc_gridfs_t`.
3243

3344
.. only:: html
3445

src/libmongoc/doc/mongoc_gridfs_t.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
mongoc_gridfs_t
44
===============
55

6+
.. warning::
7+
8+
This GridFS implementation does not conform to the `MongoDB GridFS specification <https://github.com/mongodb/specifications/blob/master/source/gridfs/gridfs-spec.rst>`_. For a spec compliant implementation, use :symbol:`mongoc_gridfs_bucket_t`.
9+
610
Synopsis
711
--------
812

@@ -42,6 +46,12 @@ Example
4246
:language: c
4347
:caption: example-gridfs.c
4448

49+
See also
50+
--------
51+
52+
- The `MongoDB GridFS specification <https://github.com/mongodb/specifications/blob/master/source/gridfs/gridfs-spec.rst>`_.
53+
- The spec-compliant :symbol:`mongoc_gridfs_bucket_t`.
54+
4555
.. only:: html
4656

4757
Functions

0 commit comments

Comments
 (0)