...

Text file src/go.mongodb.org/mongo-driver/testdata/crud/v1/write/updateOne.json

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

     1{
     2  "data": [
     3    {
     4      "_id": 1,
     5      "x": 11
     6    },
     7    {
     8      "_id": 2,
     9      "x": 22
    10    },
    11    {
    12      "_id": 3,
    13      "x": 33
    14    }
    15  ],
    16  "minServerVersion": "2.6",
    17  "tests": [
    18    {
    19      "description": "UpdateOne when many documents match",
    20      "operation": {
    21        "name": "updateOne",
    22        "arguments": {
    23          "filter": {
    24            "_id": {
    25              "$gt": 1
    26            }
    27          },
    28          "update": {
    29            "$inc": {
    30              "x": 1
    31            }
    32          }
    33        }
    34      },
    35      "outcome": {
    36        "result": {
    37          "matchedCount": 1,
    38          "modifiedCount": 1,
    39          "upsertedCount": 0
    40        }
    41      }
    42    },
    43    {
    44      "description": "UpdateOne when one document matches",
    45      "operation": {
    46        "name": "updateOne",
    47        "arguments": {
    48          "filter": {
    49            "_id": 1
    50          },
    51          "update": {
    52            "$inc": {
    53              "x": 1
    54            }
    55          }
    56        }
    57      },
    58      "outcome": {
    59        "result": {
    60          "matchedCount": 1,
    61          "modifiedCount": 1,
    62          "upsertedCount": 0
    63        },
    64        "collection": {
    65          "data": [
    66            {
    67              "_id": 1,
    68              "x": 12
    69            },
    70            {
    71              "_id": 2,
    72              "x": 22
    73            },
    74            {
    75              "_id": 3,
    76              "x": 33
    77            }
    78          ]
    79        }
    80      }
    81    },
    82    {
    83      "description": "UpdateOne when no documents match",
    84      "operation": {
    85        "name": "updateOne",
    86        "arguments": {
    87          "filter": {
    88            "_id": 4
    89          },
    90          "update": {
    91            "$inc": {
    92              "x": 1
    93            }
    94          }
    95        }
    96      },
    97      "outcome": {
    98        "result": {
    99          "matchedCount": 0,
   100          "modifiedCount": 0,
   101          "upsertedCount": 0
   102        },
   103        "collection": {
   104          "data": [
   105            {
   106              "_id": 1,
   107              "x": 11
   108            },
   109            {
   110              "_id": 2,
   111              "x": 22
   112            },
   113            {
   114              "_id": 3,
   115              "x": 33
   116            }
   117          ]
   118        }
   119      }
   120    },
   121    {
   122      "description": "UpdateOne with upsert when no documents match",
   123      "operation": {
   124        "name": "updateOne",
   125        "arguments": {
   126          "filter": {
   127            "_id": 4
   128          },
   129          "update": {
   130            "$inc": {
   131              "x": 1
   132            }
   133          },
   134          "upsert": true
   135        }
   136      },
   137      "outcome": {
   138        "result": {
   139          "matchedCount": 0,
   140          "modifiedCount": 0,
   141          "upsertedCount": 1,
   142          "upsertedId": 4
   143        },
   144        "collection": {
   145          "data": [
   146            {
   147              "_id": 1,
   148              "x": 11
   149            },
   150            {
   151              "_id": 2,
   152              "x": 22
   153            },
   154            {
   155              "_id": 3,
   156              "x": 33
   157            },
   158            {
   159              "_id": 4,
   160              "x": 1
   161            }
   162          ]
   163        }
   164      }
   165    }
   166  ]
   167}

View as plain text