@@ -4,10 +4,10 @@ BSON Documents
4
4
5
5
.. default-domain:: mongodb
6
6
7
- MongoDB is a document-based database system, and as a result all
8
- records, or data in MongoDB are documents. Documents are the default
7
+ MongoDB is a document-based database system, and as a result, all
8
+ records, or data, in MongoDB are documents. Documents are the default
9
9
representation of most user accessible data structures in the
10
- database. Document's provide structure for data in the following
10
+ database. Documents provide structure for data in the following
11
11
MongoDB contexts:
12
12
13
13
- the :ref:`records <documents-records>` stored in :term:`collections
@@ -26,10 +26,15 @@ MongoDB contexts:
26
26
- :ref:`sort order <documents-sort-order>` for the :method:`sort()
27
27
<cursor.sort()>` method.
28
28
29
- - index specification for the :method:`hint() <cursor.hint()>`
30
- method.
29
+ - :ref:`index specification <documents-index>` for the
30
+ :method:`hint() <cursor.hint()>` method.
31
31
32
- .. status output, link to examples of server stats/coll stats/etc. (?)
32
+ - the various outputs from commands and operations, such as:
33
+
34
+ - the output of :dbcommand:`collStats` command
35
+
36
+ - the output of :doc:`db.serverStatus
37
+ </reference/server-status-index>` command
33
38
34
39
Structure
35
40
---------
@@ -54,13 +59,35 @@ documents may contain field and value pairs where the value can be
54
59
another document, an array, an array of documents as well
55
60
as the basic types such as ``Double``, ``String``, or ``Date``.
56
61
57
- .. give more examples of:
62
+ Consider the following document that contains values of varying
63
+ types:
64
+
65
+ .. code-block:: javascript
66
+
67
+ {
68
+ _id: ObjectId("5099803df3f4948bd2f98391"),
69
+ name: { first: "Alan", last: "Turing" },
70
+ birth: new Date('Jun 23, 1912'),
71
+ death: new Date('Jun 07, 1954'),
72
+ contribs: [ "Turing machine", "Turing test", "Turingery" ],
73
+ views : NumberLong(1250000),
74
+ update : Timestamp(1352237167000, 1)
75
+ }
76
+
77
+ The document contains the following fields:
78
+
79
+ - field ``_id`` whose value is an *ObjectId*
80
+
81
+ - field ``name`` whose value is another *Document* that contains the
82
+ fields ``first`` and ``last``
83
+
84
+ - fields ``birth`` and ``death`` whose value is a *Date*
58
85
59
- - special bson types NumberLong(), Timestamp, etc.
86
+ - field ``contribs`` whose value is an *array of Strings*
60
87
61
- - nested document.
88
+ - field ``views`` whose value is a *NumberLong*
62
89
63
- - with arrays
90
+ - field ``update`` whose value is a *Timestamp*
64
91
65
92
Types
66
93
-----
@@ -71,17 +98,14 @@ Record Documents
71
98
~~~~~~~~~~~~~~~~
72
99
73
100
Most documents in MongoDB are records in :term:`collections` which
74
- store data from users' applications. These documents have the
75
- following limitations:
101
+ store data from users' applications.
102
+
103
+ These documents have the following limitations:
76
104
77
105
- .. include:: /includes/fact-document-max-size.rst
78
106
79
107
- .. include:: /includes/fact-document-field-name-restrictions.rst
80
108
81
- .. these should be links to the limit page or include those links. We
82
- should make these things centrally referenced to limit the number
83
- of places these data points exist *if* any of them ever change.
84
-
85
109
.. include:: /includes/note-insert-id-field.rst
86
110
87
111
The following document specifies a record in a collection:
@@ -124,19 +148,13 @@ The document contains the following fields:
124
148
Query Specification Documents
125
149
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
126
150
127
- .. this section should have a better lead in. I think we should be
128
- able to avoid the bulleted list here, which affects flow...
129
-
130
- Query selector documents may contain any or all of the following:
131
-
132
- - Simple field and value pair(s) to specify the equality
133
- condition.
134
-
135
- .. we should attempt to avoid issuing qualitative judgements about
136
- complexity or simplicity.
137
-
138
- - :doc:`Query operator </reference/operators>` expressions to specify
139
- other conditions.
151
+ Query selector documents specify the conditions that determine which
152
+ records to select for read, update, and delete operations. You can use
153
+ field and value expressions to specify the equality condition and
154
+ :doc:`query operator </reference/operators>` expressions to specify
155
+ additional conditions. Refer to :doc:`read </applications/read>`,
156
+ :doc:`update </applications/update>`, and :doc:`delete
157
+ </applications/delete>` pages for more examples.
140
158
141
159
Consider the following examples of query selector documents:
142
160
@@ -188,10 +206,12 @@ for MongoDB to return, remove, or update, as in the following:
188
206
Update Specification Documents
189
207
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
190
208
191
- .. when are they used, links to cross reference material to provide context
192
-
193
- The update actions documents contain :ref:`update operators
194
- <update-operators>` expressions.
209
+ The update action documents specify the data modifications to perform
210
+ during an :method:`update() <db.collection.update()>` operation to
211
+ modify existing records in a collection. You can use :ref:`update
212
+ operators <update-operators>` to specify the exact actions to perform
213
+ on the document fields. See the :ref:`update operators
214
+ <update-operators>` page for the available update operators and syntax.
195
215
196
216
Consider the following example of an update actions document:
197
217
@@ -227,8 +247,10 @@ When passed as an argument to the :method:`update()
227
247
Index Specifier Documents
228
248
~~~~~~~~~~~~~~~~~~~~~~~~~
229
249
230
- .. what are index documents? when are they used? cross reference links
231
- would provide a lot of the required documentation.
250
+ Indexes improve the efficiency of :doc:`read </applications/read>`
251
+ operations. Index documents specify the fields to index on during the
252
+ :method:`index creation <db.collection.ensureIndex()>` operation. See
253
+ :doc:`indexes </core/indexes>` for an overview of indexes.
232
254
233
255
The index documents contain field and value pairs where:
234
256
@@ -257,7 +279,11 @@ the index to create:
257
279
Sort Order Specification Documents
258
280
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
259
281
260
- .. where? context?
282
+ The sort order documents specify the order of documents that a
283
+ :method:`query() <db.collection.find()>` returns. The sort order
284
+ document is passed as an argument to the :method:`sort()
285
+ <cursor.sort()>` method. See the :method:`sort() <cursor.sort()>` page
286
+ for more information on sorting.
261
287
262
288
The sort order documents contain field and value pairs where:
263
289
@@ -266,7 +292,7 @@ The sort order documents contain field and value pairs where:
266
292
- the ``value`` is either 1 for ascending or -1 for descending.
267
293
268
294
The following document specifies the sort order using the fields from a
269
- subdocument ``name``: first sort by the ``last`` field ascending, then
295
+ subdocument ``name`` first sort by the ``last`` field ascending, then
270
296
by the ``first`` field also ascending:
271
297
272
298
.. code-block:: javascript
0 commit comments