Skip to content
Merged
Show file tree
Hide file tree
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
28 changes: 14 additions & 14 deletions source/fundamentals/collations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ following documents:

.. code-block:: none

{ "_id" : 1, "first_name" : "Hans" }
{ "_id" : 2, "first_name" : "Gunter" }
{ "_id" : 3, "first_name" : "Günter" }
{ "_id" : 4, "first_name" : "Jürgen" }
{ "_id" : 1, "first_name" : "Hans" }
{ "_id" : 2, "first_name" : "Gunter" }
{ "_id" : 3, "first_name" : "Günter" }
{ "_id" : 4, "first_name" : "Jürgen" }

Consider the following ``findOneAndUpdate()`` operation on this collection
which **does not** specify a collation:
Expand Down Expand Up @@ -229,9 +229,9 @@ the operation returns the following updated document:

.. code-block:: none

{ lastErrorObject: { updatedExisting: true, n: 1 },
value: { _id: 3, first_name: 'Günter' },
ok: 1 }
{ lastErrorObject: { updatedExisting: true, n: 1 },
value: { _id: 3, first_name: 'Günter' },
ok: 1 }

findOneAndDelete() Example
``````````````````````````
Expand All @@ -242,9 +242,9 @@ documents:

.. code-block:: none

{ "_id" : 1, "a" : "16" }
{ "_id" : 2, "a" : "84" }
{ "_id" : 3, "a" : "179" }
{ "_id" : 1, "a" : "16" }
{ "_id" : 2, "a" : "84" }
{ "_id" : 3, "a" : "179" }

In this example, we set the ``numericOrdering`` collation parameter to ``true``
to sort numeric strings based on their numerical order instead of their
Expand All @@ -260,8 +260,8 @@ documents:

.. code-block:: none

{ "_id" : 1, "a" : "16" }
{ "_id" : 2, "a" : "84" }
{ "_id" : 1, "a" : "16" }
{ "_id" : 2, "a" : "84" }

If you perform the same operation without collation on the original
collection of three documents, it matches documents based on the lexical value
Expand All @@ -280,8 +280,8 @@ contains the following documents:

.. code-block:: none

{ "_id" : 2, "a" : "84" }
{ "_id" : 3, "a" : "179" }
{ "_id" : 2, "a" : "84" }
{ "_id" : 3, "a" : "179" }

Aggregation Example
```````````````````
Expand Down
20 changes: 10 additions & 10 deletions source/fundamentals/crud/query-document.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,19 @@ This code snippet returns the following results:

.. code-block:: javascript

collection.find({
rating: { $eq: 5 },
qty: { $gt: 4 }
})
collection.find({
rating: { $eq: 5 },
qty: { $gt: 4 }
})

.. code-block:: javascript

collection.find({
$and: [
{ rating: { $eq: 5 }},
{ qty: { $gt: 4 }}
]
})
collection.find({
$and: [
{ rating: { $eq: 5 }},
{ qty: { $gt: 4 }}
]
})

For more information on comparison operators, see the reference manual
entry for :manual:`Comparison Query Operators </reference/operator/query-comparison/>`.
Expand Down
16 changes: 8 additions & 8 deletions source/fundamentals/logging.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ Logging
The driver doesn't use the logger in versions 4.0 and later.
Attempting to use prior logger settings in this version won't print
anything in the log.

Instead, see our monitoring guides:

- :doc:`Command Monitoring </fundamentals/monitoring/command-monitoring>`
- :doc:`Command Monitoring </fundamentals/monitoring/command-monitoring>`
- :doc:`Cluster Monitoring </fundamentals/monitoring/cluster-monitoring>`

Temporary Alternative
Expand All @@ -29,9 +29,9 @@ meantime, you can output monitor events using the following snippet:

.. code-block:: javascript

const uri = "mongodb+srv://<user>:<password>@<cluster-url>?writeConcern=majority";
const client = new MongoClient(uri, { monitorCommands:true });
client.on('commandStarted', (event) => console.debug(event));
client.on('commandSucceeded', (event) => console.debug(event));
client.on('commandFailed', (event) => console.debug(event));
const uri = "mongodb+srv://<user>:<password>@<cluster-url>?writeConcern=majority";
const client = new MongoClient(uri, { monitorCommands:true });

client.on('commandStarted', (event) => console.debug(event));
client.on('commandSucceeded', (event) => console.debug(event));
client.on('commandFailed', (event) => console.debug(event));
48 changes: 24 additions & 24 deletions source/quick-start.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,30 +137,30 @@ Connect to Your Application

.. code-block:: js

const { MongoClient } = require("mongodb");

// Replace the uri string with your connection string.
const uri =
"mongodb+srv://<user>:<password>@<cluster-url>?retryWrites=true&w=majority";

const client = new MongoClient(uri);

async function run() {
try {
const database = client.db('sample_mflix');
const movies = database.collection('movies');

// Query for a movie that has the title 'Back to the Future'
const query = { title: 'Back to the Future' };
const movie = await movies.findOne(query);

console.log(movie);
} finally {
// Ensures that the client will close when you finish/error
await client.close();
}
}
run().catch(console.dir);
const { MongoClient } = require("mongodb");

// Replace the uri string with your connection string.
const uri =
"mongodb+srv://<user>:<password>@<cluster-url>?retryWrites=true&w=majority";

const client = new MongoClient(uri);

async function run() {
try {
const database = client.db('sample_mflix');
const movies = database.collection('movies');

// Query for a movie that has the title 'Back to the Future'
const query = { title: 'Back to the Future' };
const movie = await movies.findOne(query);

console.log(movie);
} finally {
// Ensures that the client will close when you finish/error
await client.close();
}
}
run().catch(console.dir);

.. tip::

Expand Down