...

Text file src/go.mongodb.org/mongo-driver/testdata/crud/unified/bulkWrite-updateOne-dots_and_dollars.json

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

     1{
     2  "description": "bulkWrite-updateOne-dots_and_dollars",
     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          "foo": {}
    36        }
    37      ]
    38    }
    39  ],
    40  "tests": [
    41    {
    42      "description": "Updating document to set top-level dollar-prefixed key on 5.0+ server",
    43      "runOnRequirements": [
    44        {
    45          "minServerVersion": "5.0"
    46        }
    47      ],
    48      "operations": [
    49        {
    50          "name": "bulkWrite",
    51          "object": "collection0",
    52          "arguments": {
    53            "requests": [
    54              {
    55                "updateOne": {
    56                  "filter": {
    57                    "_id": 1
    58                  },
    59                  "update": [
    60                    {
    61                      "$replaceWith": {
    62                        "$setField": {
    63                          "field": {
    64                            "$literal": "$a"
    65                          },
    66                          "value": 1,
    67                          "input": "$$ROOT"
    68                        }
    69                      }
    70                    }
    71                  ]
    72                }
    73              }
    74            ]
    75          },
    76          "expectResult": {
    77            "deletedCount": 0,
    78            "insertedCount": 0,
    79            "insertedIds": {
    80              "$$unsetOrMatches": {}
    81            },
    82            "matchedCount": 1,
    83            "modifiedCount": 1,
    84            "upsertedCount": 0,
    85            "upsertedIds": {}
    86          }
    87        }
    88      ],
    89      "expectEvents": [
    90        {
    91          "client": "client0",
    92          "events": [
    93            {
    94              "commandStartedEvent": {
    95                "command": {
    96                  "update": "coll0",
    97                  "updates": [
    98                    {
    99                      "q": {
   100                        "_id": 1
   101                      },
   102                      "u": [
   103                        {
   104                          "$replaceWith": {
   105                            "$setField": {
   106                              "field": {
   107                                "$literal": "$a"
   108                              },
   109                              "value": 1,
   110                              "input": "$$ROOT"
   111                            }
   112                          }
   113                        }
   114                      ],
   115                      "multi": {
   116                        "$$unsetOrMatches": false
   117                      },
   118                      "upsert": {
   119                        "$$unsetOrMatches": false
   120                      }
   121                    }
   122                  ]
   123                }
   124              }
   125            }
   126          ]
   127        }
   128      ],
   129      "outcome": [
   130        {
   131          "collectionName": "coll0",
   132          "databaseName": "crud-tests",
   133          "documents": [
   134            {
   135              "_id": 1,
   136              "foo": {},
   137              "$a": 1
   138            }
   139          ]
   140        }
   141      ]
   142    },
   143    {
   144      "description": "Updating document to set top-level dotted key on 5.0+ server",
   145      "runOnRequirements": [
   146        {
   147          "minServerVersion": "5.0"
   148        }
   149      ],
   150      "operations": [
   151        {
   152          "name": "bulkWrite",
   153          "object": "collection0",
   154          "arguments": {
   155            "requests": [
   156              {
   157                "updateOne": {
   158                  "filter": {
   159                    "_id": 1
   160                  },
   161                  "update": [
   162                    {
   163                      "$replaceWith": {
   164                        "$setField": {
   165                          "field": {
   166                            "$literal": "a.b"
   167                          },
   168                          "value": 1,
   169                          "input": "$$ROOT"
   170                        }
   171                      }
   172                    }
   173                  ]
   174                }
   175              }
   176            ]
   177          },
   178          "expectResult": {
   179            "deletedCount": 0,
   180            "insertedCount": 0,
   181            "insertedIds": {
   182              "$$unsetOrMatches": {}
   183            },
   184            "matchedCount": 1,
   185            "modifiedCount": 1,
   186            "upsertedCount": 0,
   187            "upsertedIds": {}
   188          }
   189        }
   190      ],
   191      "expectEvents": [
   192        {
   193          "client": "client0",
   194          "events": [
   195            {
   196              "commandStartedEvent": {
   197                "command": {
   198                  "update": "coll0",
   199                  "updates": [
   200                    {
   201                      "q": {
   202                        "_id": 1
   203                      },
   204                      "u": [
   205                        {
   206                          "$replaceWith": {
   207                            "$setField": {
   208                              "field": {
   209                                "$literal": "a.b"
   210                              },
   211                              "value": 1,
   212                              "input": "$$ROOT"
   213                            }
   214                          }
   215                        }
   216                      ],
   217                      "multi": {
   218                        "$$unsetOrMatches": false
   219                      },
   220                      "upsert": {
   221                        "$$unsetOrMatches": false
   222                      }
   223                    }
   224                  ]
   225                }
   226              }
   227            }
   228          ]
   229        }
   230      ],
   231      "outcome": [
   232        {
   233          "collectionName": "coll0",
   234          "databaseName": "crud-tests",
   235          "documents": [
   236            {
   237              "_id": 1,
   238              "foo": {},
   239              "a.b": 1
   240            }
   241          ]
   242        }
   243      ]
   244    },
   245    {
   246      "description": "Updating document to set dollar-prefixed key in embedded doc on 5.0+ server",
   247      "runOnRequirements": [
   248        {
   249          "minServerVersion": "5.0"
   250        }
   251      ],
   252      "operations": [
   253        {
   254          "name": "bulkWrite",
   255          "object": "collection0",
   256          "arguments": {
   257            "requests": [
   258              {
   259                "updateOne": {
   260                  "filter": {
   261                    "_id": 1
   262                  },
   263                  "update": [
   264                    {
   265                      "$set": {
   266                        "foo": {
   267                          "$setField": {
   268                            "field": {
   269                              "$literal": "$a"
   270                            },
   271                            "value": 1,
   272                            "input": "$foo"
   273                          }
   274                        }
   275                      }
   276                    }
   277                  ]
   278                }
   279              }
   280            ]
   281          },
   282          "expectResult": {
   283            "deletedCount": 0,
   284            "insertedCount": 0,
   285            "insertedIds": {
   286              "$$unsetOrMatches": {}
   287            },
   288            "matchedCount": 1,
   289            "modifiedCount": 1,
   290            "upsertedCount": 0,
   291            "upsertedIds": {}
   292          }
   293        }
   294      ],
   295      "expectEvents": [
   296        {
   297          "client": "client0",
   298          "events": [
   299            {
   300              "commandStartedEvent": {
   301                "command": {
   302                  "update": "coll0",
   303                  "updates": [
   304                    {
   305                      "q": {
   306                        "_id": 1
   307                      },
   308                      "u": [
   309                        {
   310                          "$set": {
   311                            "foo": {
   312                              "$setField": {
   313                                "field": {
   314                                  "$literal": "$a"
   315                                },
   316                                "value": 1,
   317                                "input": "$foo"
   318                              }
   319                            }
   320                          }
   321                        }
   322                      ],
   323                      "multi": {
   324                        "$$unsetOrMatches": false
   325                      },
   326                      "upsert": {
   327                        "$$unsetOrMatches": false
   328                      }
   329                    }
   330                  ]
   331                }
   332              }
   333            }
   334          ]
   335        }
   336      ],
   337      "outcome": [
   338        {
   339          "collectionName": "coll0",
   340          "databaseName": "crud-tests",
   341          "documents": [
   342            {
   343              "_id": 1,
   344              "foo": {
   345                "$a": 1
   346              }
   347            }
   348          ]
   349        }
   350      ]
   351    },
   352    {
   353      "description": "Updating document to set dotted key in embedded doc on 5.0+ server",
   354      "runOnRequirements": [
   355        {
   356          "minServerVersion": "5.0"
   357        }
   358      ],
   359      "operations": [
   360        {
   361          "name": "bulkWrite",
   362          "object": "collection0",
   363          "arguments": {
   364            "requests": [
   365              {
   366                "updateOne": {
   367                  "filter": {
   368                    "_id": 1
   369                  },
   370                  "update": [
   371                    {
   372                      "$set": {
   373                        "foo": {
   374                          "$setField": {
   375                            "field": {
   376                              "$literal": "a.b"
   377                            },
   378                            "value": 1,
   379                            "input": "$foo"
   380                          }
   381                        }
   382                      }
   383                    }
   384                  ]
   385                }
   386              }
   387            ]
   388          },
   389          "expectResult": {
   390            "deletedCount": 0,
   391            "insertedCount": 0,
   392            "insertedIds": {
   393              "$$unsetOrMatches": {}
   394            },
   395            "matchedCount": 1,
   396            "modifiedCount": 1,
   397            "upsertedCount": 0,
   398            "upsertedIds": {}
   399          }
   400        }
   401      ],
   402      "expectEvents": [
   403        {
   404          "client": "client0",
   405          "events": [
   406            {
   407              "commandStartedEvent": {
   408                "command": {
   409                  "update": "coll0",
   410                  "updates": [
   411                    {
   412                      "q": {
   413                        "_id": 1
   414                      },
   415                      "u": [
   416                        {
   417                          "$set": {
   418                            "foo": {
   419                              "$setField": {
   420                                "field": {
   421                                  "$literal": "a.b"
   422                                },
   423                                "value": 1,
   424                                "input": "$foo"
   425                              }
   426                            }
   427                          }
   428                        }
   429                      ],
   430                      "multi": {
   431                        "$$unsetOrMatches": false
   432                      },
   433                      "upsert": {
   434                        "$$unsetOrMatches": false
   435                      }
   436                    }
   437                  ]
   438                }
   439              }
   440            }
   441          ]
   442        }
   443      ],
   444      "outcome": [
   445        {
   446          "collectionName": "coll0",
   447          "databaseName": "crud-tests",
   448          "documents": [
   449            {
   450              "_id": 1,
   451              "foo": {
   452                "a.b": 1
   453              }
   454            }
   455          ]
   456        }
   457      ]
   458    }
   459  ]
   460}

View as plain text