Skip to content

Commit e7a8739

Browse files
committed
DOCS-658 and DOCS-684 implement changes related to Jeff's comments
1 parent 3c45489 commit e7a8739

File tree

2 files changed

+59
-70
lines changed

2 files changed

+59
-70
lines changed

draft/core/document.txt

Lines changed: 46 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ Consider the following document that contains values of varying types:
6666

6767
.. code-block:: javascript
6868

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+
}
7777

7878
The document contains the following fields:
7979

@@ -94,21 +94,8 @@ To determine the type of fields, the :program:`mongo` shell provides:
9494

9595
- The ``typeof`` operator to return the type of a field.
9696

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:
11299

113100
- The following operation tests whether the ``_id`` field is of type
114101
``ObjectId``:
@@ -126,7 +113,7 @@ the ``typeof`` operators:
126113
typeof mydoc._id
127114

128115
Rather than the specific ``ObjectId`` type, the operation returns the
129-
generic ``object`` type
116+
generic ``object`` type.
130117

131118
Document Types
132119
--------------
@@ -136,10 +123,10 @@ Document Types
136123
Record Documents
137124
~~~~~~~~~~~~~~~~
138125

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.
141128

142-
These documents have the following limitations:
129+
These documents have the following attributes:
143130

144131
- .. include:: /includes/fact-document-max-size.rst
145132

@@ -198,20 +185,21 @@ Take the following considerations for the ``_id`` field:
198185
- ``ObjectId``, see the :doc:`ObjectId </core/object-id>`
199186
documentation.
200187

201-
- A sequence number, refer to the
188+
- A sequence number, see the
202189
:doc:`/tutorial/create-an-auto-incrementing-field` tutorial.
203190

204191
- UUID, your application must generate the UUID itself. For
205192
efficiency, store the UUID as a BSON BinData type to reduce the
206193
UUID values and their respective keys in the _id index by half. If,
207194
however, you know space and speed will not be an issue, you can
208195
store as a hex string.
209-
196+
210197
.. note::
211-
198+
212199
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.
215203

216204
.. _documents-query-selectors:
217205

@@ -291,6 +279,8 @@ Consider the update specification document example:
291279
$push: { awards: { award: 'IBM Fellow',
292280
year: '1963',
293281
by: 'IBM' }
282+
}
283+
}
294284

295285
When passed as an argument to the :method:`update()
296286
<db.collection.update()>` method, the update actions document:
@@ -305,15 +295,15 @@ When passed as an argument to the :method:`update()
305295

306296
.. code-block:: javascript
307297

308-
db.bios.update(
298+
db.bios.update(
309299
{ _id: 1 },
310300
{ $set: { 'name.middle': 'Warner' },
311-
$push: { awards: {
301+
$push: { awards: {
312302
award: 'IBM Fellow',
313303
year: '1963',
314-
by: 'IBM'
315-
}
316-
}
304+
by: 'IBM'
305+
}
306+
}
317307
}
318308
)
319309

@@ -441,7 +431,7 @@ type. BSON Timestamp value is a 64 bit value where:
441431

442432
- the second 32 bits are an incrementing ``ordinal`` for operations
443433
within a given second.
444-
434+
445435
On a single :program:`mongod` instance, BSON Timestamp values are guaranteed to
446436
be unique.
447437

@@ -450,7 +440,7 @@ the operation timestamp, is of type BSON Timestamp.
450440

451441
Consider the following examples of creating BSON Timestamp values:
452442

453-
.. note::
443+
.. note::
454444

455445
The BSON Timestamp type is for *internal* MongoDB use. The following
456446
examples are only for illustration purposes of the Timestamp
@@ -487,25 +477,25 @@ Consider the following examples of creating BSON Timestamp values:
487477
db.bios.insert( { views: NumberLong(0), last_updated: new Timestamp() } )
488478

489479
The Timestamp value is the empty Timestamp value (i.e. ``Timestamp(0, 0)`` ):
490-
480+
491481
.. code-block:: javascript
492-
482+
493483
{
494484
"_id" : ObjectId("50a33daf88d113a4ae94a959"),
495485
"views" : NumberLong(0),
496486
"last_updated" : Timestamp(0, 0)
497487
}
498-
488+
499489
.. versionchanged:: 2.1
500490
:program:`mongo` shell displays the Timestamp value with the wrapper:
501-
491+
502492
.. code-block:: javascript
503-
493+
504494
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+
509499
.. code-block:: javascript
510500

511501
{ t : <time_t>, i : <ordinal> }
@@ -548,19 +538,19 @@ Consider the following examples of BSON Date:
548538
- Print the month portion of the Date value; months start at zero for January :
549539

550540
.. code-block:: javascript
551-
541+
552542
mydate1.getMonth()
553543

554544
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>`_
556546
documentation.
557547

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.
564554

565555
.. note::
566556

source/tutorial/create-an-auto-incrementing-field.txt

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Create an Auto-Incrementing Sequence Field
77
Synopsis
88
--------
99

10-
In record documents, the field name ``_id`` is reserved for use as a
11-
primary key; its value must be unique in the collection. This document
10+
In documents, the field name ``_id`` is reserved for use as a primary
11+
key; its value must be unique in the collection. This document
1212
describes how to create an increasing sequence number to assign to the
1313
``_id`` field using the following:
1414

@@ -28,9 +28,9 @@ describes how to create an increasing sequence number to assign to the
2828
A Counters Collection
2929
~~~~~~~~~~~~~~~~~~~~~
3030

31-
A separate ``counters`` collection tracks the last number sequence. The
32-
``_id`` field contains the sequence name and the ``seq`` contains the
33-
last value of the sequence.
31+
A separate ``counters`` collection tracks the *last* number sequence
32+
used. The ``_id`` field contains the sequence name and the ``seq``
33+
contains the last value of the sequence.
3434

3535
1. Insert into the ``counters`` collection, the initial value for the ``userid``:
3636

@@ -43,41 +43,40 @@ last value of the sequence.
4343
}
4444
)
4545

46-
#. Create a ``getSequence`` function that accepts a ``name`` of the
46+
#. Create a ``getNextSequence`` function that accepts a ``name`` of the
4747
sequence. The function uses the :method:`findAndModify()
4848
<db.collection.findAndModify()` method to atomically increment the
4949
``seq`` value and return this new value:
5050

5151
.. code-block:: javascript
5252

53-
function getSequence(name) {
53+
function getNextSequence(name) {
5454
var ret = db.counters.findAndModify(
5555
{
5656
query: { _id: name },
5757
update: { $inc: { seq: 1 } },
58-
new: true,
59-
upsert:true
58+
new: true
6059
}
6160
);
6261

6362
return ret.seq;
6463
}
6564

66-
#. Use the ``getSequence()`` function during
65+
#. Use the ``getNextSequence()`` function during
6766
:method:`insert() <db.collection.insert()>`.
6867

6968
.. code-block:: javascript
7069

7170
db.users.insert(
7271
{
73-
_id: getSequence("userid"),
72+
_id: getNextSequence("userid"),
7473
name: "Sarah C."
7574
}
7675
)
7776

7877
db.users.insert(
7978
{
80-
_id: getSequence("userid"),
79+
_id: getNextSequence("userid"),
8180
name: "Bob D."
8281
}
8382
)
@@ -203,5 +202,5 @@ recalculating the ``_id`` value until the insert is successful.
203202
"name" : "Ted R."
204203
}
205204

206-
Extremely high concurrent insert rate on the collection could result in
207-
high iterations of the while-loop.
205+
High concurrent insert rate on the collection could result in high
206+
iterations of the while-loop.

0 commit comments

Comments
 (0)