Skip to content

Commit 90e7fe4

Browse files
committed
Update with flow delegation and address TODOs
1 parent 61aeff1 commit 90e7fe4

File tree

7 files changed

+36
-48
lines changed

7 files changed

+36
-48
lines changed

examples/src/test/kotlin/FlowTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.mongodb.ExplainVerbosity
44
import com.mongodb.kotlin.client.coroutine.MongoClient
5-
import io.github.cdimascio.dotenv.dotenv
5+
import config.getConfig
66
import kotlinx.coroutines.flow.*
77
import kotlinx.coroutines.runBlocking
88
import org.bson.Document
@@ -23,8 +23,8 @@ internal class FlowTest {
2323
val qty: Int
2424
)
2525
companion object {
26-
val dotenv = dotenv()
27-
val client = MongoClient.create(dotenv["MONGODB_CONNECTION_URI"])
26+
val config = getConfig()
27+
val client = MongoClient.create(config.connectionUri)
2828
val database = client.getDatabase("paint_store")
2929
val collection = database.getCollection<PaintOrder>("paint_order")
3030

examples/src/test/kotlin/TimeSeriesTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import com.mongodb.client.model.Filters.*
55
import com.mongodb.client.model.Projections.*
66
import com.mongodb.client.model.TimeSeriesOptions
77
import com.mongodb.kotlin.client.coroutine.MongoClient
8-
import io.github.cdimascio.dotenv.dotenv
8+
import config.getConfig
99
import kotlinx.coroutines.flow.toList
1010
import kotlinx.coroutines.runBlocking
1111
import org.bson.json.JsonWriterSettings
@@ -20,8 +20,8 @@ import kotlin.test.*
2020
internal class TimeSeriesTest {
2121

2222
companion object {
23-
val dotenv = dotenv()
24-
val mongoClient = MongoClient.create(dotenv["MONGODB_CONNECTION_URI"])
23+
val config = getConfig()
24+
val mongoClient = MongoClient.create(config.connectionUri)
2525

2626
@AfterAll
2727
@JvmStatic

source/fundamentals/crud/read-operations/flow.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
Access Data From a Flow
55
=======================
66

7-
.. default-domain:: mongodb
8-
97
.. contents:: On this page
108
:local:
119
:backlinks: none

source/quick-reference.txt

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
Quick Reference
55
===============
66

7-
.. default-domain:: mongodb
8-
97
This page shows the driver syntax for several MongoDB commands and links to
108
their related reference and API documentation.
119

@@ -350,21 +348,20 @@ The examples on the page use the following data class to represent MongoDB docum
350348

351349
- .. include:: /includes/kotlin-driver-coroutine-gradle-versioned.rst
352350

353-
.. TODO:(DOCSP-29167) add back as part of this ticket. needs refactoring b/c cursor not thing for coroutines driver
354-
.. * - | **Access Data from a Flow Iteratively**
355-
.. |
356-
.. | `API Documentation <{+api-kotlin+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCursor.html>`__
357-
.. | :ref:`Fundamentals <kotlin-fundamentals-cursor-conditional-iteration>`
358-
.. - .. io-code-block::
359-
.. :copyable: true
360-
.. .. input::
361-
.. :language: kotlin
362-
.. .. output::
363-
.. :language: console
364-
:visible: false
365-
..
366-
.. [
367-
.. { title: '2001: A Space Odyssey', ... },
368-
.. { title: 'The Sound of Music', ... },
369-
.. ...
370-
.. ]
351+
* - | **Access Data from a Flow Iteratively**
352+
|
353+
| `API Documentation <{+api-kotlin+}/apidocs/mongodb-driver-kotlin-coroutine/mongodb-driver-kotlin-coroutine/com.mongodb.kotlin.client.coroutine/-find-flow/index.html>`__
354+
| :ref:`Fundamentals <kotlin-fundamentals-flow>`
355+
356+
- .. io-code-block::
357+
:copyable: true
358+
359+
.. input:: /examples/generated/FlowTest.snippet.iterate.kt
360+
:language: kotlin
361+
362+
.. output::
363+
:language: console
364+
:visible: false
365+
366+
Movie(title=2001: A Space Odyssey, ...)
367+
Movie(title=The Sound of Music, ...)

source/usage-examples/distinct.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,13 @@ distinct values with a query filter as a second parameter, as follows:
3838
:language: kotlin
3939

4040
The ``distinct()`` method returns an object that implements the
41-
``DistinctFlow`` class, which contains methods to access,organize, and traverse
42-
the results. ``DistinctFlow`` also inherits methods from its parent class
43-
``Flow`` from the Kotlin Coroutines library, such as ``first()`` and
41+
``DistinctFlow`` class, which contains methods to access, organize, and traverse
42+
the results. ``DistinctFlow`` delegates to the ``Flow`` interface
43+
from the Kotlin Coroutines library, allowing access to methods such as ``first()`` and
4444
``firstOrNull()``.
4545

46-
.. TODO (DOCSP-29176) Add link to Flow documentation when available
47-
.. For more information, see our
48-
.. :doc:`guide on Accessing Data From a Flow </fundamentals/crud/read-operations/flow/>`.
46+
For more information, see our
47+
:doc:`guide on Accessing Data From a Flow </fundamentals/crud/read-operations/flow/>`.
4948

5049
Example
5150
-------

source/usage-examples/find.txt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,16 @@ For more information on the ``projection()`` method, see our
2828
The ``find()`` method returns an instance of ``FindFlow``, a class
2929
that offers several methods to access, organize, and traverse the results.
3030

31-
.. TODO (DOCSP-29176) Update with accurate inheritance information when available
32-
.. ``FindFlow`` also inherits methods from its parent class ``Flow`` from the
33-
.. Kotlin Coroutines library.
34-
31+
``FindFlow`` also obtains methods from its delegate interface ``Flow`` from the
32+
Kotlin Coroutines library.
3533
You can call the ``collect()`` method to iterate through the fetched results.
3634
You can also call terminal methods, such as ``firstOrNull()`` to return either
3735
the first document or ``null`` if there are no results, or ``first()`` to return
3836
the first document in the collection. If no documents match the query,
3937
calling ``first()`` throws a ``NoSuchElementException`` exception.
4038

41-
.. TODO (DOCSP-29176) Add link to Flow documentation when available
42-
.. For more information on accessing data from a flow with the Kotlin driver, see our
43-
.. :doc:`guide on Accessing Data From a Flow </fundamentals/crud/read-operations/flow/>`.
39+
For more information on accessing data from a flow with the Kotlin driver, see our
40+
:doc:`guide on Accessing Data From a Flow </fundamentals/crud/read-operations/flow/>`.
4441

4542
Example
4643
-------

source/usage-examples/findOne.txt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,15 @@ For more information on the ``projection()`` method, see our
2727
The ``find()`` method returns an instance of ``FindFlow``, a class
2828
that offers several methods to access, organize, and traverse the results.
2929

30-
.. TODO (DOCSP-29176) Update with accurate inheritance information when available
31-
.. ``FindFlow`` also inherits methods from its parent class ``Flow`` from the
32-
.. Kotlin Coroutines library, such as ``first()`` and ``firstOrNull()``.
33-
30+
``FindFlow`` also obtains methods from its delegate interface ``Flow`` from the
31+
Kotlin Coroutines library, such as ``first()`` and ``firstOrNull()``.
3432
The ``firstOrNull()`` method returns the first document from the retrieved results
3533
or ``null`` if there are no results. The ``first()`` method returns
3634
the first document or throws a ``NoSuchElementException`` exception if no
3735
documents match the query.
3836

39-
.. TODO (DOCSP-29176) Add link to Flow documentation when available
40-
.. For more information on accessing data from a flow with the Kotlin driver, see our
41-
.. :doc:`guide on Accessing Data From a Flow </fundamentals/crud/read-operations/flow/>`.
37+
For more information on accessing data from a flow with the Kotlin driver, see our
38+
:doc:`guide on Accessing Data From a Flow </fundamentals/crud/read-operations/flow/>`.
4239

4340
Example
4441
-------

0 commit comments

Comments
 (0)