Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 32 additions & 36 deletions source/reference/method/db.collection.save.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ the ``item`` field set to ``book`` and ``qty`` field set to ``40``:

.. code-block:: javascript

db.products.save( { item: "book", qty: 40 } )
db.products.save({ item: "book", qty: 40 })

The inserted document includes an ``_id`` field with the generated
``ObjectId`` value:
Expand All @@ -78,25 +78,23 @@ This example inserts a new document into the

.. code-block:: javascript

db.bios.save(
{
name: { first: 'Guido', last: 'van Rossum'},
birth: new Date('Jan 31, 1956'),
contribs: [ 'Python' ],
awards: [
{
award: 'Award for the Advancement of Free Software',
year: 2001,
by: 'Free Software Foundation'
},
{
award: 'NLUUG Award',
year: 2003,
by: 'NLUUG'
}
]
}
)
db.bios.save({
name: { first: 'Guido', last: 'van Rossum'},
birth: new Date('Jan 31, 1956'),
contribs: [ 'Python' ],
awards: [
{
award: 'Award for the Advancement of Free Software',
year: 2001,
by: 'Free Software Foundation'
},
{
award: 'NLUUG Award',
year: 2003,
by: 'NLUUG'
}
]
})

The inserted document includes an ``_id`` field with the generated
``ObjectId`` value.
Expand Down Expand Up @@ -124,7 +122,7 @@ to ``30``:

.. code-block:: javascript

db.products.save( { _id: 100, item: "water", qty: 30 } )
db.products.save({ _id: 100, item: "water", qty: 30 })

The operation results in the following new document in the ``products``
collection:
Expand All @@ -144,21 +142,19 @@ This example creates a new document in the

.. code-block:: javascript

db.bios.save(
{
_id: 10,
name: { first: 'Yukihiro', aka: 'Matz', last: 'Matsumoto'},
birth: new Date('Apr 14, 1965'),
contribs: [ 'Ruby' ],
awards: [
{
award: 'Award for the Advancement of Free Software',
year: '2011',
by: 'Free Software Foundation'
}
]
}
)
db.bios.save({
_id: 10,
name: { first: 'Yukihiro', aka: 'Matz', last: 'Matsumoto'},
birth: new Date('Apr 14, 1965'),
contribs: [ 'Ruby' ],
awards: [
{
award: 'Award for the Advancement of Free Software',
year: '2011',
by: 'Free Software Foundation'
}
]
})

Replace an Existing Document
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down