Skip to content

Commit

Permalink
vale fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rustagir committed Sep 8, 2023
1 parent 2755f69 commit 6a90ade
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion source/code-snippets/transactions/txn-convenient.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const txnResult = await client.withSession(async (session) =>
session
.withTransaction(async (session) => {
const invColl = client.db("testdb").collection("inventory");
const recColl = client.db("testdb").collection("records");
const recColl = client.db("testdb").collection("orders");

let total = 0;
for (const item of order) {
Expand Down
20 changes: 10 additions & 10 deletions source/usage-examples/transaction-conv.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ A purchase can fail for the following reasons:
- An order could not be completed
- The system went offline

If the payment fails, you can perform a transaction that includes all of
the data changes to ensure you avoid making any partial updates that
might cause data consistency issues for future operations.
You can perform a transaction to ensure you avoid
making any partial updates if any single operation in the transaction
fails.

Sample Data
~~~~~~~~~~~
Expand Down Expand Up @@ -103,7 +103,7 @@ This example code performs a transaction through the following actions:
* If the inventory is sufficient for the order, the code performs an
update operation in the ``inventory`` collection to reduce the
quantities of the items purchased.
* The code inserts a record of the purchase to the ``records``
* The code inserts a record of the purchase to the ``orders``
collection that includes a timestamp, a list of the purchased
items, and a total price for the purchase.
* The code returns a message acknowledging that the transaction
Expand All @@ -123,9 +123,9 @@ Sample Orders and Transaction Results
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When your application completes the payment transaction, the collections
in the database should contain the inventory and order updates.
If an error interrupts the transaction, none of the changes should be
visible in your database.
in the database contains the inventory and order updates.
If an error interrupts the transaction, none of the changes appear in
your database.

Suppose a customer sends the following order:

Expand Down Expand Up @@ -153,9 +153,9 @@ Given this order, the code outputs the following result:
"_id": "..."
}

In the ``inventory`` collection, you should see that the quantity of
In the ``inventory`` collection, the quantity of
``"sunblock"`` is now ``82`` and the quantity of ``"beach chair"``
is ``29``. The ``records`` collection should contain the record of the
is ``29``. The ``orders`` collection contains the record of the
purchase.

Suppose a different customer sends the following order:
Expand All @@ -175,7 +175,7 @@ Given this order, the code outputs the following result:
Item not found or insufficient quantity.

You should not see any changes in the ``inventory`` collection, and the

Check failure on line 177 in source/usage-examples/transaction-conv.txt

View workflow job for this annotation

GitHub Actions / TDBX Vale rules

[vale] reported by reviewdog 🐶 [MongoDB.AvoidSubjunctive] Avoid the subjunctive 'should'. Raw Output: {"message": "[MongoDB.AvoidSubjunctive] Avoid the subjunctive 'should'.", "location": {"path": "source/usage-examples/transaction-conv.txt", "range": {"start": {"line": 177, "column": 5}}}, "severity": "ERROR"}
``records`` collection should not have a new entry for this order.
``orders`` collection should not have a new entry for this order.

Check failure on line 178 in source/usage-examples/transaction-conv.txt

View workflow job for this annotation

GitHub Actions / TDBX Vale rules

[vale] reported by reviewdog 🐶 [MongoDB.AvoidSubjunctive] Avoid the subjunctive 'should'. Raw Output: {"message": "[MongoDB.AvoidSubjunctive] Avoid the subjunctive 'should'.", "location": {"path": "source/usage-examples/transaction-conv.txt", "range": {"start": {"line": 178, "column": 23}}}, "severity": "ERROR"}

API Documentation
-----------------
Expand Down
17 changes: 8 additions & 9 deletions source/usage-examples/transaction-core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ A purchase can fail for the following reasons:
- An order could not be completed
- The system went offline

If the payment fails, you can perform a transaction that includes all of
the data changes to ensure you avoid making any partial updates that
might cause data consistency issues for future operations.
You can perform a transaction to ensure you avoid
making any partial updates if any single operation in the transaction
fails.

Sample Data
~~~~~~~~~~~
Expand Down Expand Up @@ -159,11 +159,10 @@ Transaction Results
~~~~~~~~~~~~~~~~~~~

When your application completes the payment transaction, the collections
in the database should contain the customer and order updates.
If an error interrupts the transaction, none of the changes should be
visible in your database.
in the database contains the customer and order updates.
If an error interrupts the transaction, none of the changes appear in your database.

The ``customers`` collection should contain the customer document with an
The ``customers`` collection contains the customer document with an
order ``_id`` appended to the orders field:

.. code-block:: json
Expand All @@ -176,7 +175,7 @@ order ``_id`` appended to the orders field:
]
}

The ``inventory`` collection should contain updated quantities for the
The ``inventory`` collection contains updated quantities for the
items ``"sunblock"`` and ``"beach towel"``:

.. code-block:: json
Expand All @@ -197,7 +196,7 @@ items ``"sunblock"`` and ``"beach towel"``:
}
]

The ``orders`` collection should contain the order and payment
The ``orders`` collection contains the order and payment
information:

.. code-block:: json
Expand Down

0 comments on commit 6a90ade

Please sign in to comment.