@@ -66,14 +66,14 @@ Consider the following document that contains values of varying types:
66
66
67
67
.. code-block:: javascript
68
68
69
- {
70
- _id: ObjectId("5099803df3f4948bd2f98391"),
71
- name: { first: "Alan", last: "Turing" },
72
- birth: new Date('Jun 23, 1912'),
73
- death: new Date('Jun 07, 1954'),
74
- contribs: [ "Turing machine", "Turing test", "Turingery" ],
75
- views : NumberLong(1250000)
76
- }
69
+ var mydoc = {
70
+ _id: ObjectId("5099803df3f4948bd2f98391"),
71
+ name: { first: "Alan", last: "Turing" },
72
+ birth: new Date('Jun 23, 1912'),
73
+ death: new Date('Jun 07, 1954'),
74
+ contribs: [ "Turing machine", "Turing test", "Turingery" ],
75
+ views : NumberLong(1250000)
76
+ }
77
77
78
78
The document contains the following fields:
79
79
@@ -94,21 +94,8 @@ To determine the type of fields, the :program:`mongo` shell provides:
94
94
95
95
- The ``typeof`` operator to return the type of a field.
96
96
97
- Assume the following variable declaration/initialization:
98
-
99
- .. code-block:: javascript
100
-
101
- var mydoc = {
102
- _id: ObjectId("5099803df3f4948bd2f98391"),
103
- name: { first: "Alan", last: "Turing" },
104
- birth: new Date('Jun 23, 1912'),
105
- death: new Date('Jun 07, 1954'),
106
- contribs: [ "Turing machine", "Turing test", "Turingery" ],
107
- views : NumberLong(1250000),
108
- }
109
-
110
- The following examples demonstrate the use of the ``instanceof`` and
111
- the ``typeof`` operators:
97
+ Consider the following examples that demonstrate the use of the
98
+ ``instanceof`` and the ``typeof`` operators:
112
99
113
100
- The following operation tests whether the ``_id`` field is of type
114
101
``ObjectId``:
@@ -126,7 +113,7 @@ the ``typeof`` operators:
126
113
typeof mydoc._id
127
114
128
115
Rather than the specific ``ObjectId`` type, the operation returns the
129
- generic ``object`` type
116
+ generic ``object`` type.
130
117
131
118
Document Types
132
119
--------------
@@ -136,10 +123,10 @@ Document Types
136
123
Record Documents
137
124
~~~~~~~~~~~~~~~~
138
125
139
- Most documents in MongoDB are records in :term:`collections <collection>` which
140
- store data from users' applications.
126
+ Most documents in MongoDB in :term:`collections <collection>` store
127
+ data from users' applications.
141
128
142
- These documents have the following limitations :
129
+ These documents have the following attributes :
143
130
144
131
- .. include:: /includes/fact-document-max-size.rst
145
132
@@ -198,20 +185,21 @@ Take the following considerations for the ``_id`` field:
198
185
- ``ObjectId``, see the :doc:`ObjectId </core/object-id>`
199
186
documentation.
200
187
201
- - A sequence number, refer to the
188
+ - A sequence number, see the
202
189
:doc:`/tutorial/create-an-auto-incrementing-field` tutorial.
203
190
204
191
- UUID, your application must generate the UUID itself. For
205
192
efficiency, store the UUID as a BSON BinData type to reduce the
206
193
UUID values and their respective keys in the _id index by half. If,
207
194
however, you know space and speed will not be an issue, you can
208
195
store as a hex string.
209
-
196
+
210
197
.. note::
211
-
198
+
212
199
Different driver implementations of the UUID
213
- serialization/deserialization logic are not compatible with each
214
- other.
200
+ serialization/deserialization logic may not be fully compatible
201
+ with each other. See your specific :api:`driver documentations
202
+ <>` for details on the level of interoperability.
215
203
216
204
.. _documents-query-selectors:
217
205
@@ -291,6 +279,8 @@ Consider the update specification document example:
291
279
$push: { awards: { award: 'IBM Fellow',
292
280
year: '1963',
293
281
by: 'IBM' }
282
+ }
283
+ }
294
284
295
285
When passed as an argument to the :method:`update()
296
286
<db.collection.update()>` method, the update actions document:
@@ -305,15 +295,15 @@ When passed as an argument to the :method:`update()
305
295
306
296
.. code-block:: javascript
307
297
308
- db.bios.update(
298
+ db.bios.update(
309
299
{ _id: 1 },
310
300
{ $set: { 'name.middle': 'Warner' },
311
- $push: { awards: {
301
+ $push: { awards: {
312
302
award: 'IBM Fellow',
313
303
year: '1963',
314
- by: 'IBM'
315
- }
316
- }
304
+ by: 'IBM'
305
+ }
306
+ }
317
307
}
318
308
)
319
309
@@ -441,7 +431,7 @@ type. BSON Timestamp value is a 64 bit value where:
441
431
442
432
- the second 32 bits are an incrementing ``ordinal`` for operations
443
433
within a given second.
444
-
434
+
445
435
On a single :program:`mongod` instance, BSON Timestamp values are guaranteed to
446
436
be unique.
447
437
@@ -450,7 +440,7 @@ the operation timestamp, is of type BSON Timestamp.
450
440
451
441
Consider the following examples of creating BSON Timestamp values:
452
442
453
- .. note::
443
+ .. note::
454
444
455
445
The BSON Timestamp type is for *internal* MongoDB use. The following
456
446
examples are only for illustration purposes of the Timestamp
@@ -487,25 +477,25 @@ Consider the following examples of creating BSON Timestamp values:
487
477
db.bios.insert( { views: NumberLong(0), last_updated: new Timestamp() } )
488
478
489
479
The Timestamp value is the empty Timestamp value (i.e. ``Timestamp(0, 0)`` ):
490
-
480
+
491
481
.. code-block:: javascript
492
-
482
+
493
483
{
494
484
"_id" : ObjectId("50a33daf88d113a4ae94a959"),
495
485
"views" : NumberLong(0),
496
486
"last_updated" : Timestamp(0, 0)
497
487
}
498
-
488
+
499
489
.. versionchanged:: 2.1
500
490
:program:`mongo` shell displays the Timestamp value with the wrapper:
501
-
491
+
502
492
.. code-block:: javascript
503
-
493
+
504
494
Timestamp(<time_t>, <ordinal>)
505
-
506
- Earlier versions of the :program:`mongo` shell display the Timestamp
507
- value as a document:
508
-
495
+
496
+ Prior to version 2.1, the :program:`mongo` shell display the
497
+ Timestamp value as a document:
498
+
509
499
.. code-block:: javascript
510
500
511
501
{ t : <time_t>, i : <ordinal> }
@@ -548,19 +538,19 @@ Consider the following examples of BSON Date:
548
538
- Print the month portion of the Date value; months start at zero for January :
549
539
550
540
.. code-block:: javascript
551
-
541
+
552
542
mydate1.getMonth()
553
543
554
544
For more Date methods, see `JavaScript Date API
555
- <https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date>`_
545
+ <https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date>`_
556
546
documentation.
557
547
558
- .. [#unsigned-date] In earlier versions , Date values were incorrectly
559
- interpreted as an *unsigned* integer , adversely affecting sorts, range
560
- queries, and indexes on Date fields. Because indexes are not recreated
561
- when upgrading, please re-index if you created an index on Date values
562
- with earlier versions, and dates before 1970 are relevant to your
563
- application.
548
+ .. [#unsigned-date] Prior to version 2.0 , Date values were incorrectly
549
+ interpreted as *unsigned* integers , adversely affecting sorts, range
550
+ queries, and indexes on Date fields. Because indexes are not
551
+ recreated when upgrading, please re-index if you created an index on
552
+ Date values with earlier versions, and dates before 1970 are
553
+ relevant to your application.
564
554
565
555
.. note::
566
556
0 commit comments