...

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

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

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

View as plain text