Skip to content

Commit

Permalink
Improve rendering for bulk write JSON-like blocks (#1583)
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelatkinson authored May 10, 2024
1 parent 3afc658 commit 6b753a3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 33 deletions.
16 changes: 9 additions & 7 deletions source/crud/bulk-write.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ class BulkWriteException {

The `bulkWrite` server command has the following format:

```json
```javascript
{
"bulkWrite": 1,
"ops": <Array>,
Expand All @@ -492,7 +492,7 @@ operation should be performed as its value. The documents have the following for

#### Insert

```json
```javascript
{
"insert": <Int32>,
"document": <Document>
Expand All @@ -504,7 +504,7 @@ If the document to be inserted does not contain an `_id` field, drivers MUST gen

#### Update

```json
```javascript
{
"update": <Int32>,
"filter": <Document>,
Expand All @@ -518,7 +518,7 @@ If the document to be inserted does not contain an `_id` field, drivers MUST gen

#### Delete

```json
```javascript
{
"delete": <Int32>,
"filter": <Document>,
Expand All @@ -533,7 +533,7 @@ If the document to be inserted does not contain an `_id` field, drivers MUST gen
The `nsInfo` field is an array containing the namespaces on which the write operations should be performed. Drivers MUST
NOT include duplicate namespaces in this list. The documents in the `nsInfo` array have the following format:

```json
```javascript
{
"ns": <String>
}
Expand Down Expand Up @@ -659,7 +659,7 @@ Drivers MUST return an error if there is not room to add at least one operation

The server's response to `bulkWrite` has the following format:

```json
```javascript
{
"ok": <0 | 1>,
"cursor": {
Expand Down Expand Up @@ -690,7 +690,7 @@ command for each `getMore` call. When connected to a load balancer, drivers MUST

The documents in the results cursor have the following format:

```json
```javascript
{
"ok": <0 | 1>,
"idx": Int32,
Expand Down Expand Up @@ -850,4 +850,6 @@ batch-splitting to standardize implementations across drivers and simplify batch

## **Changelog**

- 2024-05-10: Improve rendered format for JSON-like code blocks.

- 2024-05-08: Bulk write specification created.
52 changes: 26 additions & 26 deletions source/crud/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Construct a `MongoClient` (referred to as `client`) with
CommandStartedEvents. Perform a `hello` command using `client` and record the `maxWriteBatchSize` value contained in the
response. Then, construct the following write model (referred to as `model`):

```json
```javascript
InsertOne: {
"namespace": "db.coll",
"document": { "a": "b" }
Expand Down Expand Up @@ -105,15 +105,15 @@ Construct a `MongoClient` (referred to as `client`) with
CommandStartedEvents. Perform a `hello` command using `client` and record the following values from the response:
`maxBsonObjectSize` and `maxMessageSizeBytes`. Then, construct the following document (referred to as `document`):

```json
```javascript
{
"a": "b".repeat(maxBsonObjectSize - 500)
}
```

Construct the following write model (referred to as `model`):

```json
```javascript
InsertOne: {
"namespace": "db.coll",
"document": document
Expand Down Expand Up @@ -144,7 +144,7 @@ Construct a `MongoClient` (referred to as `client`) with `retryWrites: false` co
CommandStartedEvents. Perform a `hello` command using `client` and record the `maxWriteBatchSize` value contained in the
response. Then, configure the following fail point with `client`:

```json
```javascript
{
"configureFailPoint": "failCommand",
"mode": { "times": 2 },
Expand All @@ -160,7 +160,7 @@ response. Then, configure the following fail point with `client`:

Construct the following write model (referred to as `model`):

```json
```javascript
InsertOne: {
"namespace": "db.coll",
"document": { "a": "b" }
Expand Down Expand Up @@ -192,7 +192,7 @@ response.
Construct a `MongoCollection` (referred to as `collection`) with the namespace "db.coll" (referred to as `namespace`).
Drop `collection`. Then, construct the following document (referred to as `document`):

```json
```javascript
{
"_id": 1
}
Expand All @@ -202,7 +202,7 @@ Insert `document` into `collection`.

Create the following write model (referred to as `model`):

```json
```javascript
InsertOne {
"namespace": namespace,
"document": document
Expand Down Expand Up @@ -247,7 +247,7 @@ response.
Construct a `MongoCollection` (referred to as `collection`) with the namespace "db.coll" (referred to as `namespace`).
Drop `collection`. Then create the following list of write models (referred to as `models`):

```json
```javascript
UpdateOne {
"namespace": namespace,
"filter": { "_id": "a".repeat(maxBsonObjectSize / 2) },
Expand Down Expand Up @@ -290,7 +290,7 @@ Start a session on `client` (referred to as `session`). Start a transaction on `

Create the following list of write models (referred to as `models`):

```json
```javascript
UpdateOne {
"namespace": namespace,
"filter": { "_id": "a".repeat(maxBsonObjectSize / 2) },
Expand Down Expand Up @@ -325,7 +325,7 @@ Construct a `MongoClient` (referred to as `client`) with
CommandStartedEvents. Perform a `hello` command using `client` and record the `maxBsonObjectSize` value from the
response. Then, configure the following fail point with `client`:

```json
```javascript
{
"configureFailPoint": "failCommand",
"mode": { "times": 1 },
Expand All @@ -339,7 +339,7 @@ response. Then, configure the following fail point with `client`:
Construct a `MongoCollection` (referred to as `collection`) with the namespace "db.coll" (referred to as `namespace`).
Drop `collection`. Then create the following list of write models (referred to as `models`):

```json
```javascript
UpdateOne {
"namespace": namespace,
"filter": { "_id": "a".repeat(maxBsonObjectSize / 2) },
Expand Down Expand Up @@ -377,7 +377,7 @@ Perform a `hello` command using `client` and record the following values from th

Then, construct the following document (referred to as `document`):

```json
```javascript
{
"a": "b".repeat(maxBsonObjectSize)
}
Expand All @@ -387,7 +387,7 @@ Then, construct the following document (referred to as `document`):

Construct the following write model (referred to as `model`):

```json
```javascript
InsertOne: {
"namespace": "db.coll",
"document": document
Expand All @@ -404,7 +404,7 @@ Expect a client-side error due the size.

Construct the following write model (referred to as `model`):

```json
```javascript
ReplaceOne: {
"namespace": "db.coll",
"filter": {},
Expand Down Expand Up @@ -444,7 +444,7 @@ remainderBytes = opsBytes % maxBsonObjectSize

Construct the following write model (referred to as `firstModel`):

```json
```javascript
InsertOne {
"namespace": "db.coll",
"document": { "a": "b".repeat(maxBsonObjectSize - 57) }
Expand All @@ -456,7 +456,7 @@ Create a list of write models (referred to as `models`) with `firstModel` repeat
If `remainderBytes` is greater than or equal to 217, add 1 to `numModels` and append the following write model to
`models`:

```json
```javascript
InsertOne {
"namespace": "db.coll",
"document": { "a": "b".repeat(remainderBytes - 57) }
Expand All @@ -469,7 +469,7 @@ Then perform the following two tests:

Create the following write model (referred to as `sameNamespaceModel`):

```json
```javascript
InsertOne {
"namespace": "db.coll",
"document": { "a": "b" }
Expand Down Expand Up @@ -498,7 +498,7 @@ Construct the following namespace (referred to as `namespace`):

Create the following write model (referred to as `newNamespaceModel`):

```json
```javascript
InsertOne {
"namespace": namespace,
"document": { "a": "b" }
Expand Down Expand Up @@ -532,7 +532,7 @@ changed in the bulk write specification.

The command document for the `bulkWrite` has the following structure and size:

```json
```javascript
{
"bulkWrite": 1,
"errorsOnly": true,
Expand All @@ -544,7 +544,7 @@ Size: 43 bytes

Each write model will create an `ops` document with the following structure and size:

```json
```javascript
{
"insert": <0 | 1>,
"document": {
Expand All @@ -561,7 +561,7 @@ total of 58 bytes.

The models using the "db.coll" namespace will create one `nsInfo` document with the following structure and size:

```json
```javascript
{
"ns": "db.coll"
}
Expand All @@ -571,7 +571,7 @@ Size: 21 bytes

`newNamespaceModel` will create an `nsInfo` document with the following structure and size:

```json
```javascript
{
"ns": "db.<c repeated 200 times>"
}
Expand Down Expand Up @@ -613,7 +613,7 @@ Construct a `MongoClient` (referred to as `client`). Perform a `hello` command u

Construct the following write model (referred to as `largeDocumentModel`):

```json
```javascript
InsertOne {
"namespace": "db.coll",
"document": { "a": "b".repeat(maxMessageSizeBytes) }
Expand All @@ -633,7 +633,7 @@ Construct the following namespace (referred to as `namespace`):

Construct the following write model (referred to as `largeNamespaceModel`):

```json
```javascript
InsertOne {
"namespace": namespace,
"document": { "a": "b" }
Expand All @@ -653,7 +653,7 @@ This test must only be run on 8.0+ servers.

Construct a `MongoClient` (referred to as `client`) configured with the following `AutoEncryptionOpts`:

```json
```javascript
AutoEncryptionOpts {
"keyVaultNamespace": "db.coll",
"kmsProviders": {
Expand All @@ -667,7 +667,7 @@ AutoEncryptionOpts {

Construct the following write model (referred to as `model`):

```json
```javascript
InsertOne {
"namespace": "db.coll",
"document": { "a": "b" }
Expand Down

0 comments on commit 6b753a3

Please sign in to comment.