@@ -25,8 +25,8 @@ distinct values of a specified field across a collection.
25
25
26
26
Within a collection, different documents might contain different values for a
27
27
single field. For example, one document in a ``restaurants`` collection has a
28
- ``borough`` value of ``" Manhattan" ``, and another has a ``borough`` value of
29
- ``" Queens" ``. By using the {+php-library+}, you can retrieve all the unique values
28
+ ``borough`` value of ``' Manhattan' ``, and another has a ``borough`` value of
29
+ ``' Queens' ``. By using the {+php-library+}, you can retrieve all the unique values
30
30
that a field contains across multiple documents in a collection.
31
31
32
32
Sample Data
@@ -59,6 +59,7 @@ The following example retrieves the distinct values of the ``borough`` field in
59
59
the ``restaurants`` collection:
60
60
61
61
.. io-code-block::
62
+ :copyable:
62
63
63
64
.. input:: /includes/read/distinct.php
64
65
:start-after: start-distinct
@@ -67,10 +68,13 @@ the ``restaurants`` collection:
67
68
:dedent:
68
69
69
70
.. output::
71
+ :visible: false
70
72
71
- { "values" : [ "Bronx", "Brooklyn", "Manhattan", "Missing", "Queens", "Staten Island" ],
72
- "ok" : 1.0, "$clusterTime" : { "clusterTime" : { "$timestamp" : { ... } },
73
- "signature" : { "hash" : { ... }, "keyId" : ... } }, "operationTime" : { "$timestamp" : { ... } }
73
+ "Bronx"
74
+ "Manhattan"
75
+ "Missing"
76
+ "Queens"
77
+ "Staten Island"
74
78
75
79
The operation returns an array that stores each distinct ``borough`` field value. Although
76
80
several documents have the same value in the ``borough`` field, each value appears in the
@@ -88,6 +92,7 @@ The following example retrieves the distinct values of the ``borough`` field for
88
92
all documents that have a ``cuisine`` field value of ``'Italian'``:
89
93
90
94
.. io-code-block::
95
+ :copyable:
91
96
92
97
.. input:: /includes/read/distinct.php
93
98
:start-after: start-distinct-with-query
@@ -96,10 +101,12 @@ all documents that have a ``cuisine`` field value of ``'Italian'``:
96
101
:dedent:
97
102
98
103
.. output::
104
+ :visible: false
99
105
100
- { "values" : [ "Bronx", "Brooklyn", "Manhattan", "Queens", "Staten Island" ],
101
- "ok" : 1.0, "$clusterTime" : { "clusterTime" : { "$timestamp" : { ... },
102
- "signature" : { "hash" : { ... }, "keyId" : ... } }, "operationTime" : { "$timestamp" : { ... } }
106
+ "Bronx"
107
+ "Manhattan"
108
+ "Queens"
109
+ "Staten Island"
103
110
104
111
Modify Distinct Behavior
105
112
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -138,6 +145,7 @@ all documents that have a ``borough`` field value of ``'Bronx'`` and a
138
145
in an options array to add a comment to the operation:
139
146
140
147
.. io-code-block::
148
+ :copyable:
141
149
142
150
.. input:: /includes/read/distinct.php
143
151
:start-after: start-distinct-with-comment
@@ -146,9 +154,16 @@ in an options array to add a comment to the operation:
146
154
:dedent:
147
155
148
156
.. output::
149
-
150
- { "values" : [ "$1.25 Pizza", "18 East Gunhill Pizza", "2 Bros", "Aenos Pizza", "Alitalia Pizza Restaurant", … ],
151
- "ok" : 1.0, "$clusterTime" : { "clusterTime" : { … }, "signature" : { … }, "keyId" : … } }, "operationTime" : { … } }
157
+ :visible: false
158
+
159
+ "$1.25 Pizza"
160
+ "18 East Gunhill Pizza"
161
+ "2 Bros"
162
+ "Aenos Pizza"
163
+ "Alitalia Pizza Restaurant"
164
+ "Amici Pizza And Pasta"
165
+ "Angie'S Cafe Pizza"
166
+ ...
152
167
153
168
API Documentation
154
169
-----------------
0 commit comments