MONGO D B LINK PACKAGE SYMBOL

UpdateDocument


updates (or upserts) a document (list of rules) in a collection.

DetailsDetails

  • UpdateDocument returns the number of documents that were modified. If no documents match the query, it will return 0.
  • The following options can be given:
  • "WriteConcern""Acknowledged"Write concern to use.
    "Upsert"FalseInsert new documents if no existing documents match the query.
    "Multi"FalseAllow more than one document to be updated in a single operation.
  • Valid options for WriteConcern are "Acknowledged", "FSynced", "Journaled", "Majority", "Unacknowledged" and "ReplicaAcknowledged". For a description of these options, see the MongoDB documentation.

ExamplesExamplesopen allclose all

Basic Examples  (2)Basic Examples  (2)

Open a database connection, get the database and get the collection:

In[1]:=
Click for copyable input

Insert test documents:

In[2]:=
Click for copyable input

Documents before the update:

In[3]:=
Click for copyable input
Out[3]=

Make an update:

In[4]:=
Click for copyable input
Out[4]=

Documents after the update:

In[5]:=
Click for copyable input
Out[5]=

A basic update replaces the entire document. Use "$set" to change the value of the specified fields:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=