diff --git a/source/core/index-sparse.txt b/source/core/index-sparse.txt index fb28dcb889e..afa4d21b062 100644 --- a/source/core/index-sparse.txt +++ b/source/core/index-sparse.txt @@ -125,7 +125,7 @@ The collection has a sparse index on the field ``score``: .. code-block:: javascript - db.scores.createIndex( { score: 1 } , { sparse: true } ) + db.scores.createIndex( { score: 1 } , { sparse: true } ) Then, the following query on the ``scores`` collection uses the sparse index to return the documents that have the ``score`` field less than @@ -160,7 +160,7 @@ The collection has a sparse index on the field ``score``: .. code-block:: javascript - db.scores.createIndex( { score: 1 } , { sparse: true } ) + db.scores.createIndex( { score: 1 } , { sparse: true } ) Because the document for the userid ``"newbie"`` does not contain the ``score`` field, the sparse index does not contain an entry for that @@ -221,7 +221,7 @@ the following operation: .. code-block:: javascript - db.scores.createIndex( { score: 1 } , { sparse: true, unique: true } ) + db.scores.createIndex( { score: 1 } , { sparse: true, unique: true } ) This index *would permit* the insertion of documents that had unique values for the ``score`` field *or* did not include a ``score`` field. diff --git a/source/core/query-optimization.txt b/source/core/query-optimization.txt index 04c014a69b1..57689a08ab9 100644 --- a/source/core/query-optimization.txt +++ b/source/core/query-optimization.txt @@ -110,7 +110,7 @@ For example, a collection ``inventory`` has the following index on the .. code-block:: javascript - db.inventory.createIndex( { type: 1, item: 1 } ) + db.inventory.createIndex( { type: 1, item: 1 } ) This index will cover the following operation which queries on the ``type`` and ``item`` fields and returns only the ``item`` field: diff --git a/source/includes/example-push-each.rst b/source/includes/example-push-each.rst index 417f386a29d..9bc52578497 100644 --- a/source/includes/example-push-each.rst +++ b/source/includes/example-push-each.rst @@ -4,7 +4,7 @@ equals ``joe``: .. code-block:: javascript - db.students.update( - { name: "joe" }, - { $push: { scores: { $each: [ 90, 92, 85 ] } } } - ) + db.students.update( + { name: "joe" }, + { $push: { scores: { $each: [ 90, 92, 85 ] } } } + ) diff --git a/source/includes/output-upgrade-check.rst b/source/includes/output-upgrade-check.rst index 91f6441c02c..cf3b2fcc548 100644 --- a/source/includes/output-upgrade-check.rst +++ b/source/includes/output-upgrade-check.rst @@ -47,7 +47,7 @@ Warning Output .. code-block:: none - Warning: upgradeCheck only supports V1 indexes. Skipping index: + Warning: upgradeCheck only supports V1 indexes. Skipping index: To resolve, remove the invalid index and recreate the index omitting the version specification, or reindex the collection. Reindex operation diff --git a/source/reference/command/collStats.txt b/source/reference/command/collStats.txt index f15e54748f2..6c0c7f3202d 100644 --- a/source/reference/command/collStats.txt +++ b/source/reference/command/collStats.txt @@ -129,7 +129,7 @@ The following operation runs the :dbcommand:`collStats` command on the .. code-block:: javascript - db.runCommand( { collStats : "restaurants", scale: 1024 } ) + db.runCommand( { collStats : "restaurants", scale: 1024 } ) The following document provides a representation of the :dbcommand:`collStats` output. Depending on the configuration of your diff --git a/source/reference/command/currentOp.txt b/source/reference/command/currentOp.txt index f28264779a0..44c977c97d3 100644 --- a/source/reference/command/currentOp.txt +++ b/source/reference/command/currentOp.txt @@ -174,14 +174,14 @@ database ``db1`` that have been running longer than 3 seconds: .. code-block:: javascript - db.adminCommand( - { - currentOp: true, - "active" : true, - "secs_running" : { "$gt" : 3 }, - "ns" : /^db1\./ - } - ) + db.adminCommand( + { + currentOp: true, + "active" : true, + "secs_running" : { "$gt" : 3 }, + "ns" : /^db1\./ + } + ) .. _currentOp-cmd-index-creation: diff --git a/source/reference/command/dataSize.txt b/source/reference/command/dataSize.txt index 4dece3b0c3f..eee67ed19a0 100644 --- a/source/reference/command/dataSize.txt +++ b/source/reference/command/dataSize.txt @@ -102,7 +102,7 @@ and the upper bound of the key to be examined being ``{field: 100}``. .. code-block:: javascript - db.runCommand({ dataSize: "database.collection", keyPattern: { field: 1 }, min: { field: 10 }, max: { field: 100 } }) + db.runCommand({ dataSize: "database.collection", keyPattern: { field: 1 }, min: { field: 10 }, max: { field: 100 } }) This will return a document that contains the size of all matching documents. Replace ``database.collection`` value with database diff --git a/source/reference/command/findAndModify.txt b/source/reference/command/findAndModify.txt index 65d2b73ec2a..7e3e0d7bc03 100644 --- a/source/reference/command/findAndModify.txt +++ b/source/reference/command/findAndModify.txt @@ -556,11 +556,11 @@ following form: .. code-block:: javascript - db.people.findAndModify( { - query: { name: "Tom", state: "active", rating: { $gt: 10 } }, - sort: { rating: 1 }, - update: { $inc: { score: 1 } } - } ); + db.people.findAndModify( { + query: { name: "Tom", state: "active", rating: { $gt: 10 } }, + sort: { rating: 1 }, + update: { $inc: { score: 1 } } + } ); However, the :method:`~db.collection.findAndModify()` shell helper method returns only the unmodified document, or if ``new`` is @@ -585,15 +585,15 @@ document or, if no matching document exists, create a new document: .. code-block:: javascript - db.runCommand( - { - findAndModify: "people", - query: { name: "Gus", state: "active", rating: 100 }, - sort: { rating: 1 }, - update: { $inc: { score: 1 } }, - upsert: true - } - ) + db.runCommand( + { + findAndModify: "people", + query: { name: "Gus", state: "active", rating: 100 }, + sort: { rating: 1 }, + update: { $inc: { score: 1 } }, + upsert: true + } + ) If the command finds a matching document, the command performs an update. diff --git a/source/reference/command/removeShard.txt b/source/reference/command/removeShard.txt index 14cb8a0806c..affcfe27622 100644 --- a/source/reference/command/removeShard.txt +++ b/source/reference/command/removeShard.txt @@ -25,7 +25,7 @@ against the ``admin`` database: .. code-block:: javascript - db.adminCommand( { removeShard : } ) + db.adminCommand( { removeShard : } ) Behavior -------- diff --git a/source/reference/command/usersInfo.txt b/source/reference/command/usersInfo.txt index 682689e4664..38015fb1ada 100644 --- a/source/reference/command/usersInfo.txt +++ b/source/reference/command/usersInfo.txt @@ -248,7 +248,7 @@ that resembles the following: .. code-block:: javascript - db.runCommand( { usersInfo: 1 } ) + db.runCommand( { usersInfo: 1 } ) When viewing all users, you can specify the ``showCredentials`` option but not the ``showPrivileges`` or the diff --git a/source/reference/command/validate.txt b/source/reference/command/validate.txt index 6b5197dd12e..bc0c99fe4d5 100644 --- a/source/reference/command/validate.txt +++ b/source/reference/command/validate.txt @@ -130,7 +130,7 @@ Examples .. code-block:: javascript - db.runCommand( { validate: "myCollection", full: true } ) + db.runCommand( { validate: "myCollection", full: true } ) - To repair collection ``myCollection``, specify :ref:`repair: true `: diff --git a/source/reference/installation-ubuntu-community-troubleshooting.txt b/source/reference/installation-ubuntu-community-troubleshooting.txt index 67d2df010bc..46b3f8dad06 100644 --- a/source/reference/installation-ubuntu-community-troubleshooting.txt +++ b/source/reference/installation-ubuntu-community-troubleshooting.txt @@ -79,7 +79,7 @@ by running the following command in the terminal: .. code-block:: text - sudo apt-key list + sudo apt-key list The output should include an entry that resembles the following: diff --git a/source/reference/method/db.collection.bulkWrite.txt b/source/reference/method/db.collection.bulkWrite.txt index 595ed25b34e..c2b68583629 100644 --- a/source/reference/method/db.collection.bulkWrite.txt +++ b/source/reference/method/db.collection.bulkWrite.txt @@ -400,16 +400,16 @@ five operations. .. code-block:: javascript - db.collection.bulkWrite( - [ - { insertOne : }, - { updateOne : }, - { updateMany : }, - { replaceOne : }, - { deleteOne : }, - { deleteMany : } - ] - ) + db.collection.bulkWrite( + [ + { insertOne : }, + { updateOne : }, + { updateMany : }, + { replaceOne : }, + { deleteOne : }, + { deleteMany : } + ] + ) In the default ``ordered : true`` state, each operation will be executed in order, from the first operation ``insertOne`` @@ -424,17 +424,17 @@ The following code represents an unordered .. code-block:: javascript - db.collection.bulkWrite( - [ - { insertOne : }, - { updateOne : }, - { updateMany : }, - { replaceOne : }, - { deleteOne : }, - { deleteMany : } - ], - { ordered : false } - ) + db.collection.bulkWrite( + [ + { insertOne : }, + { updateOne : }, + { updateMany : }, + { replaceOne : }, + { deleteOne : }, + { deleteMany : } + ], + { ordered : false } + ) With ``ordered : false``, the results of the operation may vary. For example, the ``deleteOne`` or ``deleteMany`` may remove more or fewer documents diff --git a/source/reference/method/db.collection.hideIndex.txt b/source/reference/method/db.collection.hideIndex.txt index e8a09e8fdd8..742c0abe7fc 100644 --- a/source/reference/method/db.collection.hideIndex.txt +++ b/source/reference/method/db.collection.hideIndex.txt @@ -134,7 +134,7 @@ To verify, run :method:`db.collection.getIndexes()` on the .. code-block:: javascript - db.restaurants.getIndexes(); + db.restaurants.getIndexes(); The operation returns the following information: diff --git a/source/reference/method/db.currentOp.txt b/source/reference/method/db.currentOp.txt index f9d6a975144..747a6422db3 100644 --- a/source/reference/method/db.currentOp.txt +++ b/source/reference/method/db.currentOp.txt @@ -204,13 +204,13 @@ database ``db1`` that have been running longer than 3 seconds: .. code-block:: javascript - db.currentOp( - { - "active" : true, - "secs_running" : { "$gt" : 3 }, - "ns" : /^db1\./ - } - ) + db.currentOp( + { + "active" : true, + "secs_running" : { "$gt" : 3 }, + "ns" : /^db1\./ + } + ) .. _currentOp-index-creation: diff --git a/source/reference/method/isInteractive.txt b/source/reference/method/isInteractive.txt index 792bc80a537..debeb910d05 100644 --- a/source/reference/method/isInteractive.txt +++ b/source/reference/method/isInteractive.txt @@ -55,7 +55,7 @@ Connect a :binary:`~bin.mongo` shell to a deployment. Inside the .. code-block:: javascript - let loadStatus = load("testExample.js"); //You may need to specify the path to the file + let loadStatus = load("testExample.js"); //You may need to specify the path to the file The method returns in the :binary:`~bin.mongo` shell: diff --git a/source/reference/operator/aggregation/dateFromString.txt b/source/reference/operator/aggregation/dateFromString.txt index da7e1d5bb92..d611536c447 100644 --- a/source/reference/operator/aggregation/dateFromString.txt +++ b/source/reference/operator/aggregation/dateFromString.txt @@ -210,16 +210,16 @@ to a date object: .. code-block:: javascript - db.logmessages.aggregate( [ { - $project: { - date: { - $dateFromString: { - dateString: '$date', - timezone: 'America/New_York' - } - } - } - } ] ) + db.logmessages.aggregate( [ { + $project: { + date: { + $dateFromString: { + dateString: '$date', + timezone: 'America/New_York' + } + } + } + } ] ) The above aggregation returns the following documents and converts each ``date`` field to the Eastern Time Zone: @@ -237,16 +237,16 @@ hard coded argument. For example: .. code-block:: javascript - db.logmessages.aggregate( [ { - $project: { - date: { - $dateFromString: { - dateString: '$date', - timezone: '$timezone' - } - } - } - } ] ) + db.logmessages.aggregate( [ { + $project: { + date: { + $dateFromString: { + dateString: '$date', + timezone: '$timezone' + } + } + } + } ] ) The above aggregation returns the following documents and converts each ``date`` field to their respective UTC representations. diff --git a/source/reference/operator/aggregation/first-array-element.txt b/source/reference/operator/aggregation/first-array-element.txt index 9fad15c8757..000af0cc2fd 100644 --- a/source/reference/operator/aggregation/first-array-element.txt +++ b/source/reference/operator/aggregation/first-array-element.txt @@ -159,9 +159,9 @@ information for the first run and the last run: .. code-block:: javascript - db.runninglog.aggregate([ - { $addFields: { firstrun: { $first: "$log" }, lastrun: { $last: "$log" } } } - ]) + db.runninglog.aggregate([ + { $addFields: { firstrun: { $first: "$log" }, lastrun: { $last: "$log" } } } + ]) The operation returns the following results: diff --git a/source/reference/operator/aggregation/last-array-element.txt b/source/reference/operator/aggregation/last-array-element.txt index 5dd5aaafced..a0019e2b878 100644 --- a/source/reference/operator/aggregation/last-array-element.txt +++ b/source/reference/operator/aggregation/last-array-element.txt @@ -157,9 +157,9 @@ information for the first run and the last run: .. code-block:: javascript - db.runninglog.aggregate([ - { $addFields: { firstrun: { $first: "$log" }, lastrun: { $last: "$log" } } } - ]) + db.runninglog.aggregate([ + { $addFields: { firstrun: { $first: "$log" }, lastrun: { $last: "$log" } } } + ]) The operation returns the following results: diff --git a/source/reference/operator/aggregation/match.txt b/source/reference/operator/aggregation/match.txt index a417961759d..fb5b2be17c1 100644 --- a/source/reference/operator/aggregation/match.txt +++ b/source/reference/operator/aggregation/match.txt @@ -126,10 +126,10 @@ the documents: .. code-block:: javascript - db.articles.aggregate( [ - { $match: { $or: [ { score: { $gt: 70, $lt: 90 } }, { views: { $gte: 1000 } } ] } }, - { $group: { _id: null, count: { $sum: 1 } } } - ] ); + db.articles.aggregate( [ + { $match: { $or: [ { score: { $gt: 70, $lt: 90 } }, { views: { $gte: 1000 } } ] } }, + { $group: { _id: null, count: { $sum: 1 } } } + ] ); In the aggregation pipeline, :pipeline:`$match` selects the documents where either the ``score`` is greater than ``70`` and less than ``90`` diff --git a/source/reference/operator/aggregation/range.txt b/source/reference/operator/aggregation/range.txt index 7ed3eb25553..95388e24ea4 100644 --- a/source/reference/operator/aggregation/range.txt +++ b/source/reference/operator/aggregation/range.txt @@ -104,13 +104,13 @@ the stopping points for each trip. .. code-block:: javascript - db.distances.aggregate([{ - $project: { - _id: 0, - city: 1, - "Rest stops": { $range: [ 0, "$distance", 25 ] } - } - }]) + db.distances.aggregate([{ + $project: { + _id: 0, + city: 1, + "Rest stops": { $range: [ 0, "$distance", 25 ] } + } + }]) The operation returns the following: diff --git a/source/reference/operator/aggregation/redact.txt b/source/reference/operator/aggregation/redact.txt index 3f0fe438631..cd165139c1c 100644 --- a/source/reference/operator/aggregation/redact.txt +++ b/source/reference/operator/aggregation/redact.txt @@ -203,20 +203,20 @@ fields contained in a document/embedded document at level ``5``, include a .. code-block:: javascript - db.accounts.aggregate( - [ - { $match: { status: "A" } }, - { - $redact: { - $cond: { - if: { $eq: [ "$level", 5 ] }, - then: "$$PRUNE", - else: "$$DESCEND" - } - } - } - ] - ); + db.accounts.aggregate( + [ + { $match: { status: "A" } }, + { + $redact: { + $cond: { + if: { $eq: [ "$level", 5 ] }, + then: "$$PRUNE", + else: "$$DESCEND" + } + } + } + ] + ); The :pipeline:`$redact` stage evaluates the ``level`` field to determine access. If the ``level`` field equals ``5``, then exclude all diff --git a/source/reference/operator/aggregation/reduce.txt b/source/reference/operator/aggregation/reduce.txt index 44b32009d7b..38afb105389 100644 --- a/source/reference/operator/aggregation/reduce.txt +++ b/source/reference/operator/aggregation/reduce.txt @@ -273,36 +273,36 @@ The following example reduces the ``hobbies`` array of strings into a single str .. code-block:: javascript - db.people.aggregate( - [ - // Filter to return only non-empty arrays - { $match: { "hobbies": { $gt: [ ] } } }, - { - $project: { - "name": 1, - "bio": { - $reduce: { - input: "$hobbies", - initialValue: "My hobbies include:", - in: { - $concat: [ - "$$value", - { - $cond: { - if: { $eq: [ "$$value", "My hobbies include:" ] }, - then: " ", - else: ", " - } - }, - "$$this" - ] - } - } - } - } - } - ] - ) + db.people.aggregate( + [ + // Filter to return only non-empty arrays + { $match: { "hobbies": { $gt: [ ] } } }, + { + $project: { + "name": 1, + "bio": { + $reduce: { + input: "$hobbies", + initialValue: "My hobbies include:", + in: { + $concat: [ + "$$value", + { + $cond: { + if: { $eq: [ "$$value", "My hobbies include:" ] }, + then: " ", + else: ", " + } + }, + "$$this" + ] + } + } + } + } + } + ] + ) The operation returns the following: diff --git a/source/reference/operator/aggregation/regexFind.txt b/source/reference/operator/aggregation/regexFind.txt index 48ed653d176..fd7f7167c3b 100644 --- a/source/reference/operator/aggregation/regexFind.txt +++ b/source/reference/operator/aggregation/regexFind.txt @@ -520,12 +520,12 @@ Create a sample collection ``feedback`` with the following documents: .. code-block:: javascript - db.feedback.insertMany([ - { "_id" : 1, comment: "Hi, I'm just reading about MongoDB -- aunt.arc.tica@example.com" }, - { "_id" : 2, comment: "I wanted to concatenate a string" }, - { "_id" : 3, comment: "How do I convert a date to string? cam@mongodb.com" }, - { "_id" : 4, comment: "It's just me. I'm testing. fred@MongoDB.com" } - ]) + db.feedback.insertMany([ + { "_id" : 1, comment: "Hi, I'm just reading about MongoDB -- aunt.arc.tica@example.com" }, + { "_id" : 2, comment: "I wanted to concatenate a string" }, + { "_id" : 3, comment: "How do I convert a date to string? cam@mongodb.com" }, + { "_id" : 4, comment: "It's just me. I'm testing. fred@MongoDB.com" } + ]) The following aggregation uses the :expression:`$regexFind` to extract the email from the ``comment`` field (case insensitive). @@ -585,16 +585,16 @@ the ``details`` array into an embedded document with an ``email`` and .. code-block:: javascript - db.contacts.aggregate( [ - { $unwind: "$details" }, - { $addFields: { - "regexemail": { $regexFind: { input: "$details", regex: /^[a-z0-9_.+-]+@[a-z0-9_.+-]+\.[a-z0-9_.+-]+$/, options: "i" } }, - "regexphone": { $regexFind: { input: "$details", regex: /^[+]{0,1}[0-9]*\-?[0-9_\-]+$/ } } - } }, - { $project: { _id: 1, name: 1, details: { email: "$regexemail.match", phone: "$regexphone.match" } } }, - { $group: { _id: "$_id", name: { $first: "$name" }, details: { $mergeObjects: "$details"} } }, - { $sort: { _id: 1 } } - ]) + db.contacts.aggregate( [ + { $unwind: "$details" }, + { $addFields: { + "regexemail": { $regexFind: { input: "$details", regex: /^[a-z0-9_.+-]+@[a-z0-9_.+-]+\.[a-z0-9_.+-]+$/, options: "i" } }, + "regexphone": { $regexFind: { input: "$details", regex: /^[+]{0,1}[0-9]*\-?[0-9_\-]+$/ } } + } }, + { $project: { _id: 1, name: 1, details: { email: "$regexemail.match", phone: "$regexphone.match" } } }, + { $group: { _id: "$_id", name: { $first: "$name" }, details: { $mergeObjects: "$details"} } }, + { $sort: { _id: 1 } } + ]) First Stage The stage :pipeline:`$unwinds <$unwind>` the array into separate diff --git a/source/reference/operator/aggregation/subtract.txt b/source/reference/operator/aggregation/subtract.txt index ba280a21d72..a53d1ca6b56 100644 --- a/source/reference/operator/aggregation/subtract.txt +++ b/source/reference/operator/aggregation/subtract.txt @@ -54,7 +54,7 @@ subtotal of ``price`` and ``fee``. .. code-block:: javascript - db.sales.aggregate( [ { $project: { item: 1, total: { $subtract: [ { $add: [ "$price", "$fee" ] }, "$discount" ] } } } ] ) + db.sales.aggregate( [ { $project: { item: 1, total: { $subtract: [ { $add: [ "$price", "$fee" ] }, "$discount" ] } } } ] ) The operation returns the following results: @@ -73,13 +73,13 @@ milliseconds: .. code-block:: javascript - db.sales.aggregate( [ { $project: { item: 1, dateDifference: { $subtract: [ "$$NOW", "$date" ] } } } ] ) + db.sales.aggregate( [ { $project: { item: 1, dateDifference: { $subtract: [ "$$NOW", "$date" ] } } } ] ) Alternatively, you can use the :method:`Date()` for the current date:s .. code-block:: javascript - db.sales.aggregate( [ { $project: { item: 1, dateDifference: { $subtract: [ new Date(), "$date" ] } } } ] ) + db.sales.aggregate( [ { $project: { item: 1, dateDifference: { $subtract: [ new Date(), "$date" ] } } } ] ) Both operations return documents that resemble the following: @@ -97,7 +97,7 @@ field: .. code-block:: javascript - db.sales.aggregate( [ { $project: { item: 1, dateDifference: { $subtract: [ "$date", 5 * 60 * 1000 ] } } } ] ) + db.sales.aggregate( [ { $project: { item: 1, dateDifference: { $subtract: [ "$date", 5 * 60 * 1000 ] } } } ] ) The operation returns the following results: diff --git a/source/reference/operator/aggregation/unset.txt b/source/reference/operator/aggregation/unset.txt index 20d3de073de..1c000e215ce 100644 --- a/source/reference/operator/aggregation/unset.txt +++ b/source/reference/operator/aggregation/unset.txt @@ -137,9 +137,9 @@ embedded field ``first`` (from the ``name`` document) and the embedded field .. code-block:: javascript - db.books.aggregate([ - { $unset: [ "isbn", "author.first", "copies.warehouse" ] } - ]) + db.books.aggregate([ + { $unset: [ "isbn", "author.first", "copies.warehouse" ] } + ]) The :pipeline:`$unset` operation outputs the following documents: diff --git a/source/reference/operator/query/bitsAnySet.txt b/source/reference/operator/query/bitsAnySet.txt index ec5801b8efd..55410735703 100644 --- a/source/reference/operator/query/bitsAnySet.txt +++ b/source/reference/operator/query/bitsAnySet.txt @@ -70,7 +70,7 @@ whether field ``a`` has any bits set at positions ``0``, ``1``, and ``5`` .. code-block:: javascript - db.collection.find( { a: { $bitsAnySet: 35 } } ) + db.collection.find( { a: { $bitsAnySet: 35 } } ) The query matches the following documents: diff --git a/source/reference/operator/query/jsonSchema.txt b/source/reference/operator/query/jsonSchema.txt index 3aa9cc49c4d..7dbca4a9dfa 100644 --- a/source/reference/operator/query/jsonSchema.txt +++ b/source/reference/operator/query/jsonSchema.txt @@ -278,8 +278,8 @@ collection that satisfy the schema: .. code-block:: javascript - db.inventory.find( { $jsonSchema: myschema } ) - db.inventory.aggregate( [ { $match: { $jsonSchema: myschema } } ] ) + db.inventory.find( { $jsonSchema: myschema } ) + db.inventory.aggregate( [ { $match: { $jsonSchema: myschema } } ] ) You can use :query:`$jsonSchema` with the :query:`$nor` to find all documents that do not satisfy the schema: diff --git a/source/reference/operator/update/mul.txt b/source/reference/operator/update/mul.txt index 057654d751b..0ac2e62bc27 100644 --- a/source/reference/operator/update/mul.txt +++ b/source/reference/operator/update/mul.txt @@ -131,10 +131,10 @@ that does not exist in the document: .. code-block:: javascript - db.products.update( - { _id: 2 }, - { $mul: { price: NumberLong(100) } } - ) + db.products.update( + { _id: 2 }, + { $mul: { price: NumberLong(100) } } + ) The operation results in the following document with a ``price`` field set to value 0 of numeric type :ref:`shell-type-long`, the same type as @@ -160,10 +160,10 @@ The following :method:`db.collection.update()` operation uses the .. code-block:: javascript - db.products.update( - { _id: 3 }, - { $mul: { price: NumberInt(5) } } - ) + db.products.update( + { _id: 3 }, + { $mul: { price: NumberInt(5) } } + ) The operation results in the following document: diff --git a/source/reference/operator/update/positional-all.txt b/source/reference/operator/update/positional-all.txt index 214f1b138c0..d27813e3489 100644 --- a/source/reference/operator/update/positional-all.txt +++ b/source/reference/operator/update/positional-all.txt @@ -57,11 +57,11 @@ array field: .. code-block:: javascript - db.collection.update( - { myArray: [ 5, 8 ] }, - { $set: { "myArray.$[]": 10 } }, - { upsert: true } - ) + db.collection.update( + { myArray: [ 5, 8 ] }, + { $set: { "myArray.$[]": 10 } }, + { upsert: true } + ) If no such document exists, the operation would result in an insertion of the following document: @@ -79,17 +79,17 @@ documents were found to update: .. code-block:: javascript - db.collection.update( - { myArray: 5 }, - { $set: { "myArray.$[]": 10 } }, - { upsert: true } - ) - - db.collection.update( - { }, - { $set: { "myArray.$[]": 10 } }, - { upsert: true } - ) + db.collection.update( + { myArray: 5 }, + { $set: { "myArray.$[]": 10 } }, + { upsert: true } + ) + + db.collection.update( + { }, + { $set: { "myArray.$[]": 10 } }, + { upsert: true } + ) Nested Arrays ~~~~~~~~~~~~~ diff --git a/source/release-notes/3.4-compatibility.txt b/source/release-notes/3.4-compatibility.txt index 49b6eb5d151..b4198895cb2 100644 --- a/source/release-notes/3.4-compatibility.txt +++ b/source/release-notes/3.4-compatibility.txt @@ -305,10 +305,10 @@ is successful because of this behavior: .. code-block:: javascript - db.c.drop() - db.c.update( { a : { $in : [1] } }, { $addToSet : { a : 2 } }, { upsert : true } ) - db.c.find() - { "_id" : ObjectId("58bdb00eb39e8f87607e9222"), "a" : [ 2 ] } + db.c.drop() + db.c.update( { a : { $in : [1] } }, { $addToSet : { a : 2 } }, { upsert : true } ) + db.c.find() + { "_id" : ObjectId("58bdb00eb39e8f87607e9222"), "a" : [ 2 ] } In 3.4 and newer versions, however, a single-element :query:`$in` behaves like an equality statement for upserts. If the query includes this condition diff --git a/source/release-notes/4.0-upgrade-replica-set.txt b/source/release-notes/4.0-upgrade-replica-set.txt index e19ed494517..17e1501840b 100644 --- a/source/release-notes/4.0-upgrade-replica-set.txt +++ b/source/release-notes/4.0-upgrade-replica-set.txt @@ -138,7 +138,7 @@ replica set member and check the ``featureCompatibilityVersion``: .. code-block:: javascript - db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ) + db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ) All members should return a result that includes ``"featureCompatibilityVersion" : { "version" : "3.6" }``. @@ -149,7 +149,7 @@ members must be available: .. code-block:: javascript - db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } ) + db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } ) For more information, see :dbcommand:`setFeatureCompatibilityVersion`. diff --git a/source/release-notes/4.2-upgrade-replica-set.txt b/source/release-notes/4.2-upgrade-replica-set.txt index c09b8f0dfd7..9628c632e4a 100644 --- a/source/release-notes/4.2-upgrade-replica-set.txt +++ b/source/release-notes/4.2-upgrade-replica-set.txt @@ -103,7 +103,7 @@ replica set member and check the ``featureCompatibilityVersion``: .. code-block:: javascript - db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ) + db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ) All members should return a result that includes ``"featureCompatibilityVersion" : { "version" : "4.0" }``. @@ -114,7 +114,7 @@ members must be available: .. code-block:: javascript - db.adminCommand( { setFeatureCompatibilityVersion: "4.0" } ) + db.adminCommand( { setFeatureCompatibilityVersion: "4.0" } ) For more information, see :dbcommand:`setFeatureCompatibilityVersion`. diff --git a/source/release-notes/4.4-upgrade-replica-set.txt b/source/release-notes/4.4-upgrade-replica-set.txt index 220381cb36d..829d8e07bad 100644 --- a/source/release-notes/4.4-upgrade-replica-set.txt +++ b/source/release-notes/4.4-upgrade-replica-set.txt @@ -61,7 +61,7 @@ replica set member and check the ``featureCompatibilityVersion``: .. code-block:: javascript - db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ) + db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ) All members should return a result that includes ``"featureCompatibilityVersion" : { "version" : "4.2" }``. @@ -72,7 +72,7 @@ members must be available: .. code-block:: javascript - db.adminCommand( { setFeatureCompatibilityVersion: "4.2" } ) + db.adminCommand( { setFeatureCompatibilityVersion: "4.2" } ) For more information, see :dbcommand:`setFeatureCompatibilityVersion`. diff --git a/source/tutorial/configure-mongo-shell.txt b/source/tutorial/configure-mongo-shell.txt index 17a5552c036..f4664c66aa6 100644 --- a/source/tutorial/configure-mongo-shell.txt +++ b/source/tutorial/configure-mongo-shell.txt @@ -57,11 +57,11 @@ To create a :binary:`~bin.mongo` shell prompt in the form of .. code-block:: javascript - host = db.serverStatus().host; + host = db.serverStatus().host; - prompt = function() { - return db+"@"+host+"$ "; - } + prompt = function() { + return db+"@"+host+"$ "; + } The prompt would then resemble the following: @@ -87,7 +87,7 @@ The prompt would then resemble the following: .. code-block:: javascript - Uptime:5897 Documents:6 > + Uptime:5897 Documents:6 > Use an External Editor in the ``mongo`` Shell --------------------------------------------- diff --git a/source/tutorial/deploy-sharded-cluster-with-keyfile-access-control.txt b/source/tutorial/deploy-sharded-cluster-with-keyfile-access-control.txt index 3db83edb24c..6774a6e52b6 100644 --- a/source/tutorial/deploy-sharded-cluster-with-keyfile-access-control.txt +++ b/source/tutorial/deploy-sharded-cluster-with-keyfile-access-control.txt @@ -104,8 +104,8 @@ Create the Keyfile .. code-block:: bash - openssl rand -base64 756 > - chmod 400 + openssl rand -base64 756 > + chmod 400 See :ref:`internal-auth-keyfile` for additional details and requirements for using keyfiles. diff --git a/source/tutorial/enforce-keyfile-access-control-in-existing-sharded-cluster-no-downtime.txt b/source/tutorial/enforce-keyfile-access-control-in-existing-sharded-cluster-no-downtime.txt index 7329c94db34..31ae7994869 100644 --- a/source/tutorial/enforce-keyfile-access-control-in-existing-sharded-cluster-no-downtime.txt +++ b/source/tutorial/enforce-keyfile-access-control-in-existing-sharded-cluster-no-downtime.txt @@ -103,8 +103,8 @@ Create and Distribute the Keyfile .. code-block:: bash - openssl rand -base64 755 > - chmod 400 + openssl rand -base64 755 > + chmod 400 .. include:: /includes/extracts/keyfile-distribution-sharded-cluster.rst @@ -164,17 +164,17 @@ roles: .. code-block:: javascript - admin = db.getSiblingDB("admin") - admin.createUser( - { - user: "admin", - pwd: passwordPrompt(), // or cleartext password - roles: [ - { role: "clusterAdmin", db: "admin" }, - { role: "userAdmin", db: "admin" } - ] - } - ) + admin = db.getSiblingDB("admin") + admin.createUser( + { + user: "admin", + pwd: passwordPrompt(), // or cleartext password + roles: [ + { role: "clusterAdmin", db: "admin" }, + { role: "userAdmin", db: "admin" } + ] + } + ) At the completion of this tutorial, if you want to connect to the shard to perform maintenance operation that require direct connection to a