...

Text file src/go.mongodb.org/mongo-driver/testdata/crud/unified/updateMany-let.json

Documentation: go.mongodb.org/mongo-driver/testdata/crud/unified

     1{
     2  "description": "updateMany-let",
     3  "schemaVersion": "1.0",
     4  "createEntities": [
     5    {
     6      "client": {
     7        "id": "client0",
     8        "observeEvents": [
     9          "commandStartedEvent"
    10        ]
    11      }
    12    },
    13    {
    14      "database": {
    15        "id": "database0",
    16        "client": "client0",
    17        "databaseName": "crud-tests"
    18      }
    19    },
    20    {
    21      "collection": {
    22        "id": "collection0",
    23        "database": "database0",
    24        "collectionName": "coll0"
    25      }
    26    }
    27  ],
    28  "initialData": [
    29    {
    30      "collectionName": "coll0",
    31      "databaseName": "crud-tests",
    32      "documents": [
    33        {
    34          "_id": 1
    35        },
    36        {
    37          "_id": 2,
    38          "name": "name"
    39        },
    40        {
    41          "_id": 3,
    42          "name": "name"
    43        }
    44      ]
    45    }
    46  ],
    47  "tests": [
    48    {
    49      "description": "updateMany with let option",
    50      "runOnRequirements": [
    51        {
    52          "minServerVersion": "5.0"
    53        }
    54      ],
    55      "operations": [
    56        {
    57          "name": "updateMany",
    58          "object": "collection0",
    59          "arguments": {
    60            "filter": {
    61              "$expr": {
    62                "$eq": [
    63                  "$name",
    64                  "$$name"
    65                ]
    66              }
    67            },
    68            "update": [
    69              {
    70                "$set": {
    71                  "x": "$$x",
    72                  "y": "$$y"
    73                }
    74              }
    75            ],
    76            "let": {
    77              "name": "name",
    78              "x": "foo",
    79              "y": {
    80                "$literal": "bar"
    81              }
    82            }
    83          },
    84          "expectResult": {
    85            "matchedCount": 2,
    86            "modifiedCount": 2,
    87            "upsertedCount": 0
    88          }
    89        }
    90      ],
    91      "expectEvents": [
    92        {
    93          "client": "client0",
    94          "events": [
    95            {
    96              "commandStartedEvent": {
    97                "command": {
    98                  "update": "coll0",
    99                  "updates": [
   100                    {
   101                      "q": {
   102                        "$expr": {
   103                          "$eq": [
   104                            "$name",
   105                            "$$name"
   106                          ]
   107                        }
   108                      },
   109                      "u": [
   110                        {
   111                          "$set": {
   112                            "x": "$$x",
   113                            "y": "$$y"
   114                          }
   115                        }
   116                      ],
   117                      "multi": true,
   118                      "upsert": {
   119                        "$$unsetOrMatches": false
   120                      }
   121                    }
   122                  ],
   123                  "let": {
   124                    "name": "name",
   125                    "x": "foo",
   126                    "y": {
   127                      "$literal": "bar"
   128                    }
   129                  }
   130                }
   131              }
   132            }
   133          ]
   134        }
   135      ],
   136      "outcome": [
   137        {
   138          "collectionName": "coll0",
   139          "databaseName": "crud-tests",
   140          "documents": [
   141            {
   142              "_id": 1
   143            },
   144            {
   145              "_id": 2,
   146              "name": "name",
   147              "x": "foo",
   148              "y": "bar"
   149            },
   150            {
   151              "_id": 3,
   152              "name": "name",
   153              "x": "foo",
   154              "y": "bar"
   155            }
   156          ]
   157        }
   158      ]
   159    },
   160    {
   161      "description": "updateMany with let option unsupported (server-side error)",
   162      "runOnRequirements": [
   163        {
   164          "minServerVersion": "4.2.0",
   165          "maxServerVersion": "4.4.99"
   166        }
   167      ],
   168      "operations": [
   169        {
   170          "name": "updateMany",
   171          "object": "collection0",
   172          "arguments": {
   173            "filter": {
   174              "_id": 1
   175            },
   176            "update": [
   177              {
   178                "$set": {
   179                  "x": "$$x"
   180                }
   181              }
   182            ],
   183            "let": {
   184              "x": "foo"
   185            }
   186          },
   187          "expectError": {
   188            "errorContains": "'update.let' is an unknown field",
   189            "isClientError": false
   190          }
   191        }
   192      ],
   193      "expectEvents": [
   194        {
   195          "client": "client0",
   196          "events": [
   197            {
   198              "commandStartedEvent": {
   199                "command": {
   200                  "update": "coll0",
   201                  "updates": [
   202                    {
   203                      "q": {
   204                        "_id": 1
   205                      },
   206                      "u": [
   207                        {
   208                          "$set": {
   209                            "x": "$$x"
   210                          }
   211                        }
   212                      ],
   213                      "multi": true,
   214                      "upsert": {
   215                        "$$unsetOrMatches": false
   216                      }
   217                    }
   218                  ],
   219                  "let": {
   220                    "x": "foo"
   221                  }
   222                }
   223              }
   224            }
   225          ]
   226        }
   227      ],
   228      "outcome": [
   229        {
   230          "collectionName": "coll0",
   231          "databaseName": "crud-tests",
   232          "documents": [
   233            {
   234              "_id": 1
   235            },
   236            {
   237              "_id": 2,
   238              "name": "name"
   239            },
   240            {
   241              "_id": 3,
   242              "name": "name"
   243            }
   244          ]
   245        }
   246      ]
   247    }
   248  ]
   249}

View as plain text