...

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

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

     1{
     2  "description": "updateWithPipelines",
     3  "schemaVersion": "1.0",
     4  "runOnRequirements": [
     5    {
     6      "minServerVersion": "4.1.11"
     7    }
     8  ],
     9  "createEntities": [
    10    {
    11      "client": {
    12        "id": "client0",
    13        "observeEvents": [
    14          "commandStartedEvent"
    15        ]
    16      }
    17    },
    18    {
    19      "database": {
    20        "id": "database0",
    21        "client": "client0",
    22        "databaseName": "crud-tests"
    23      }
    24    },
    25    {
    26      "collection": {
    27        "id": "collection0",
    28        "database": "database0",
    29        "collectionName": "test"
    30      }
    31    }
    32  ],
    33  "initialData": [
    34    {
    35      "collectionName": "test",
    36      "databaseName": "crud-tests",
    37      "documents": [
    38        {
    39          "_id": 1,
    40          "x": 1,
    41          "y": 1,
    42          "t": {
    43            "u": {
    44              "v": 1
    45            }
    46          }
    47        },
    48        {
    49          "_id": 2,
    50          "x": 2,
    51          "y": 1
    52        }
    53      ]
    54    }
    55  ],
    56  "tests": [
    57    {
    58      "description": "UpdateOne using pipelines",
    59      "operations": [
    60        {
    61          "object": "collection0",
    62          "name": "updateOne",
    63          "arguments": {
    64            "filter": {
    65              "_id": 1
    66            },
    67            "update": [
    68              {
    69                "$replaceRoot": {
    70                  "newRoot": "$t"
    71                }
    72              },
    73              {
    74                "$addFields": {
    75                  "foo": 1
    76                }
    77              }
    78            ]
    79          },
    80          "expectResult": {
    81            "matchedCount": 1,
    82            "modifiedCount": 1,
    83            "upsertedCount": 0
    84          }
    85        }
    86      ],
    87      "expectEvents": [
    88        {
    89          "client": "client0",
    90          "events": [
    91            {
    92              "commandStartedEvent": {
    93                "command": {
    94                  "update": "test",
    95                  "updates": [
    96                    {
    97                      "q": {
    98                        "_id": 1
    99                      },
   100                      "u": [
   101                        {
   102                          "$replaceRoot": {
   103                            "newRoot": "$t"
   104                          }
   105                        },
   106                        {
   107                          "$addFields": {
   108                            "foo": 1
   109                          }
   110                        }
   111                      ],
   112                      "multi": {
   113                        "$$unsetOrMatches": false
   114                      },
   115                      "upsert": {
   116                        "$$unsetOrMatches": false
   117                      }
   118                    }
   119                  ]
   120                },
   121                "commandName": "update",
   122                "databaseName": "crud-tests"
   123              }
   124            }
   125          ]
   126        }
   127      ],
   128      "outcome": [
   129        {
   130          "collectionName": "test",
   131          "databaseName": "crud-tests",
   132          "documents": [
   133            {
   134              "_id": 1,
   135              "u": {
   136                "v": 1
   137              },
   138              "foo": 1
   139            },
   140            {
   141              "_id": 2,
   142              "x": 2,
   143              "y": 1
   144            }
   145          ]
   146        }
   147      ]
   148    },
   149    {
   150      "description": "UpdateMany using pipelines",
   151      "operations": [
   152        {
   153          "object": "collection0",
   154          "name": "updateMany",
   155          "arguments": {
   156            "filter": {},
   157            "update": [
   158              {
   159                "$project": {
   160                  "x": 1
   161                }
   162              },
   163              {
   164                "$addFields": {
   165                  "foo": 1
   166                }
   167              }
   168            ]
   169          },
   170          "expectResult": {
   171            "matchedCount": 2,
   172            "modifiedCount": 2,
   173            "upsertedCount": 0
   174          }
   175        }
   176      ],
   177      "expectEvents": [
   178        {
   179          "client": "client0",
   180          "events": [
   181            {
   182              "commandStartedEvent": {
   183                "command": {
   184                  "update": "test",
   185                  "updates": [
   186                    {
   187                      "q": {},
   188                      "u": [
   189                        {
   190                          "$project": {
   191                            "x": 1
   192                          }
   193                        },
   194                        {
   195                          "$addFields": {
   196                            "foo": 1
   197                          }
   198                        }
   199                      ],
   200                      "multi": true,
   201                      "upsert": {
   202                        "$$unsetOrMatches": false
   203                      }
   204                    }
   205                  ]
   206                },
   207                "commandName": "update",
   208                "databaseName": "crud-tests"
   209              }
   210            }
   211          ]
   212        }
   213      ],
   214      "outcome": [
   215        {
   216          "collectionName": "test",
   217          "databaseName": "crud-tests",
   218          "documents": [
   219            {
   220              "_id": 1,
   221              "x": 1,
   222              "foo": 1
   223            },
   224            {
   225              "_id": 2,
   226              "x": 2,
   227              "foo": 1
   228            }
   229          ]
   230        }
   231      ]
   232    },
   233    {
   234      "description": "FindOneAndUpdate using pipelines",
   235      "operations": [
   236        {
   237          "object": "collection0",
   238          "name": "findOneAndUpdate",
   239          "arguments": {
   240            "filter": {
   241              "_id": 1
   242            },
   243            "update": [
   244              {
   245                "$project": {
   246                  "x": 1
   247                }
   248              },
   249              {
   250                "$addFields": {
   251                  "foo": 1
   252                }
   253              }
   254            ]
   255          }
   256        }
   257      ],
   258      "expectEvents": [
   259        {
   260          "client": "client0",
   261          "events": [
   262            {
   263              "commandStartedEvent": {
   264                "command": {
   265                  "findAndModify": "test",
   266                  "update": [
   267                    {
   268                      "$project": {
   269                        "x": 1
   270                      }
   271                    },
   272                    {
   273                      "$addFields": {
   274                        "foo": 1
   275                      }
   276                    }
   277                  ]
   278                },
   279                "commandName": "findAndModify",
   280                "databaseName": "crud-tests"
   281              }
   282            }
   283          ]
   284        }
   285      ],
   286      "outcome": [
   287        {
   288          "collectionName": "test",
   289          "databaseName": "crud-tests",
   290          "documents": [
   291            {
   292              "_id": 1,
   293              "x": 1,
   294              "foo": 1
   295            },
   296            {
   297              "_id": 2,
   298              "x": 2,
   299              "y": 1
   300            }
   301          ]
   302        }
   303      ]
   304    },
   305    {
   306      "description": "UpdateOne in bulk write using pipelines",
   307      "operations": [
   308        {
   309          "object": "collection0",
   310          "name": "bulkWrite",
   311          "arguments": {
   312            "requests": [
   313              {
   314                "updateOne": {
   315                  "filter": {
   316                    "_id": 1
   317                  },
   318                  "update": [
   319                    {
   320                      "$replaceRoot": {
   321                        "newRoot": "$t"
   322                      }
   323                    },
   324                    {
   325                      "$addFields": {
   326                        "foo": 1
   327                      }
   328                    }
   329                  ]
   330                }
   331              }
   332            ]
   333          },
   334          "expectResult": {
   335            "matchedCount": 1,
   336            "modifiedCount": 1,
   337            "upsertedCount": 0
   338          }
   339        }
   340      ],
   341      "expectEvents": [
   342        {
   343          "client": "client0",
   344          "events": [
   345            {
   346              "commandStartedEvent": {
   347                "command": {
   348                  "update": "test",
   349                  "updates": [
   350                    {
   351                      "q": {
   352                        "_id": 1
   353                      },
   354                      "u": [
   355                        {
   356                          "$replaceRoot": {
   357                            "newRoot": "$t"
   358                          }
   359                        },
   360                        {
   361                          "$addFields": {
   362                            "foo": 1
   363                          }
   364                        }
   365                      ],
   366                      "multi": {
   367                        "$$unsetOrMatches": false
   368                      },
   369                      "upsert": {
   370                        "$$unsetOrMatches": false
   371                      }
   372                    }
   373                  ]
   374                },
   375                "commandName": "update",
   376                "databaseName": "crud-tests"
   377              }
   378            }
   379          ]
   380        }
   381      ],
   382      "outcome": [
   383        {
   384          "collectionName": "test",
   385          "databaseName": "crud-tests",
   386          "documents": [
   387            {
   388              "_id": 1,
   389              "u": {
   390                "v": 1
   391              },
   392              "foo": 1
   393            },
   394            {
   395              "_id": 2,
   396              "x": 2,
   397              "y": 1
   398            }
   399          ]
   400        }
   401      ]
   402    },
   403    {
   404      "description": "UpdateMany in bulk write using pipelines",
   405      "operations": [
   406        {
   407          "object": "collection0",
   408          "name": "bulkWrite",
   409          "arguments": {
   410            "requests": [
   411              {
   412                "updateMany": {
   413                  "filter": {},
   414                  "update": [
   415                    {
   416                      "$project": {
   417                        "x": 1
   418                      }
   419                    },
   420                    {
   421                      "$addFields": {
   422                        "foo": 1
   423                      }
   424                    }
   425                  ]
   426                }
   427              }
   428            ]
   429          },
   430          "expectResult": {
   431            "matchedCount": 2,
   432            "modifiedCount": 2,
   433            "upsertedCount": 0
   434          }
   435        }
   436      ],
   437      "expectEvents": [
   438        {
   439          "client": "client0",
   440          "events": [
   441            {
   442              "commandStartedEvent": {
   443                "command": {
   444                  "update": "test",
   445                  "updates": [
   446                    {
   447                      "q": {},
   448                      "u": [
   449                        {
   450                          "$project": {
   451                            "x": 1
   452                          }
   453                        },
   454                        {
   455                          "$addFields": {
   456                            "foo": 1
   457                          }
   458                        }
   459                      ],
   460                      "multi": true,
   461                      "upsert": {
   462                        "$$unsetOrMatches": false
   463                      }
   464                    }
   465                  ]
   466                },
   467                "commandName": "update",
   468                "databaseName": "crud-tests"
   469              }
   470            }
   471          ]
   472        }
   473      ],
   474      "outcome": [
   475        {
   476          "collectionName": "test",
   477          "databaseName": "crud-tests",
   478          "documents": [
   479            {
   480              "_id": 1,
   481              "x": 1,
   482              "foo": 1
   483            },
   484            {
   485              "_id": 2,
   486              "x": 2,
   487              "foo": 1
   488            }
   489          ]
   490        }
   491      ]
   492    }
   493  ]
   494}

View as plain text