{
  "description": "client bulkWrite update pipeline",
  "schemaVersion": "1.1",
  "runOnRequirements": [
    {
      "minServerVersion": "8.0"
    }
  ],
  "createEntities": [
    {
      "client": {
        "id": "client0",
        "observeEvents": [
          "commandStartedEvent"
        ]
      }
    },
    {
      "database": {
        "id": "database0",
        "client": "client0",
        "databaseName": "crud-tests"
      }
    },
    {
      "collection": {
        "id": "collection0",
        "database": "database0",
        "collectionName": "coll0"
      }
    }
  ],
  "initialData": [
    {
      "collectionName": "coll0",
      "databaseName": "crud-tests",
      "documents": [
        {
          "_id": 1,
          "x": 1
        },
        {
          "_id": 2,
          "x": 2
        }
      ]
    }
  ],
  "_yamlAnchors": {
    "namespace": "crud-tests.coll0"
  },
  "tests": [
    {
      "description": "client bulkWrite updateOne with pipeline",
      "operations": [
        {
          "object": "client0",
          "name": "clientBulkWrite",
          "arguments": {
            "models": [
              {
                "updateOne": {
                  "namespace": "crud-tests.coll0",
                  "filter": {
                    "_id": 1
                  },
                  "update": [
                    {
                      "$addFields": {
                        "foo": 1
                      }
                    }
                  ]
                }
              }
            ],
            "verboseResults": true
          },
          "expectResult": {
            "insertedCount": 0,
            "upsertedCount": 0,
            "matchedCount": 1,
            "modifiedCount": 1,
            "deletedCount": 0,
            "insertResults": {},
            "updateResults": {
              "0": {
                "matchedCount": 1,
                "modifiedCount": 1,
                "upsertedId": {
                  "$$exists": false
                }
              }
            },
            "deleteResults": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client0",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "bulkWrite",
                "databaseName": "admin",
                "command": {
                  "bulkWrite": 1,
                  "errorsOnly": false,
                  "ordered": true,
                  "ops": [
                    {
                      "update": 0,
                      "filter": {
                        "_id": 1
                      },
                      "updateMods": [
                        {
                          "$addFields": {
                            "foo": 1
                          }
                        }
                      ],
                      "multi": false
                    }
                  ],
                  "nsInfo": [
                    {
                      "ns": "crud-tests.coll0"
                    }
                  ]
                }
              }
            }
          ]
        }
      ],
      "outcome": [
        {
          "databaseName": "crud-tests",
          "collectionName": "coll0",
          "documents": [
            {
              "_id": 1,
              "x": 1,
              "foo": 1
            },
            {
              "_id": 2,
              "x": 2
            }
          ]
        }
      ]
    },
    {
      "description": "client bulkWrite updateMany with pipeline",
      "operations": [
        {
          "object": "client0",
          "name": "clientBulkWrite",
          "arguments": {
            "models": [
              {
                "updateMany": {
                  "namespace": "crud-tests.coll0",
                  "filter": {},
                  "update": [
                    {
                      "$addFields": {
                        "foo": 1
                      }
                    }
                  ]
                }
              }
            ],
            "verboseResults": true
          },
          "expectResult": {
            "insertedCount": 0,
            "upsertedCount": 0,
            "matchedCount": 2,
            "modifiedCount": 2,
            "deletedCount": 0,
            "insertResults": {},
            "updateResults": {
              "0": {
                "matchedCount": 2,
                "modifiedCount": 2,
                "upsertedId": {
                  "$$exists": false
                }
              }
            },
            "deleteResults": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client0",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "bulkWrite",
                "databaseName": "admin",
                "command": {
                  "bulkWrite": 1,
                  "errorsOnly": false,
                  "ordered": true,
                  "ops": [
                    {
                      "update": 0,
                      "filter": {},
                      "updateMods": [
                        {
                          "$addFields": {
                            "foo": 1
                          }
                        }
                      ],
                      "multi": true
                    }
                  ],
                  "nsInfo": [
                    {
                      "ns": "crud-tests.coll0"
                    }
                  ]
                }
              }
            }
          ]
        }
      ],
      "outcome": [
        {
          "databaseName": "crud-tests",
          "collectionName": "coll0",
          "documents": [
            {
              "_id": 1,
              "x": 1,
              "foo": 1
            },
            {
              "_id": 2,
              "x": 2,
              "foo": 1
            }
          ]
        }
      ]
    }
  ]
}
