...

Text file src/go.mongodb.org/mongo-driver/testdata/crud/v1/write/replaceOne.yml

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

     1data:
     2    - {_id: 1, x: 11}
     3    - {_id: 2, x: 22}
     4    - {_id: 3, x: 33}
     5minServerVersion: '2.6'
     6
     7tests:
     8    -
     9        description: "ReplaceOne when many documents match"
    10        operation:
    11            name: "replaceOne"
    12            arguments:
    13                filter: 
    14                    _id: {$gt: 1}
    15                replacement: {x: 111}
    16
    17        outcome:
    18            result:
    19                matchedCount: 1
    20                modifiedCount: 1
    21                upsertedCount: 0
    22            # Can't verify collection data because we don't have a way of
    23            # knowing which document gets updated.
    24    -
    25        description: "ReplaceOne when one document matches"
    26        operation:
    27            name: "replaceOne"
    28            arguments:
    29                filter: {_id: 1}
    30                replacement: {_id: 1, x: 111}
    31
    32        outcome:
    33            result:
    34                matchedCount: 1
    35                modifiedCount: 1
    36                upsertedCount: 0
    37            collection:
    38                data:
    39                    - {_id: 1, x: 111}
    40                    - {_id: 2, x: 22}
    41                    - {_id: 3, x: 33}
    42    -
    43        description: "ReplaceOne when no documents match"
    44        operation:
    45            name: "replaceOne"
    46            arguments:
    47                filter: {_id: 4}
    48                replacement: {_id: 4, x: 1}
    49
    50        outcome:
    51            result:
    52                matchedCount: 0
    53                modifiedCount: 0
    54                upsertedCount: 0
    55            collection:
    56                data:
    57                    - {_id: 1, x: 11}
    58                    - {_id: 2, x: 22}
    59                    - {_id: 3, x: 33}
    60    -
    61        description: "ReplaceOne with upsert when no documents match without an id specified"
    62        operation:
    63            name: "replaceOne"
    64            arguments:
    65                filter: {_id: 4}
    66                replacement: {x: 1}
    67                upsert: true
    68
    69        outcome:
    70            result:
    71                matchedCount: 0
    72                modifiedCount: 0
    73                upsertedCount: 1
    74                upsertedId: 4
    75            collection:
    76                data:
    77                    - {_id: 1, x: 11}
    78                    - {_id: 2, x: 22}
    79                    - {_id: 3, x: 33}
    80                    - {_id: 4, x: 1}
    81
    82    -
    83        description: "ReplaceOne with upsert when no documents match with an id specified"
    84        operation:
    85            name: "replaceOne"
    86            arguments:
    87                filter: {_id: 4}
    88                replacement: {_id: 4, x: 1}
    89                upsert: true
    90
    91        outcome:
    92            result:
    93                matchedCount: 0
    94                modifiedCount: 0
    95                upsertedCount: 1
    96                upsertedId: 4
    97            collection:
    98                data:
    99                    - {_id: 1, x: 11}
   100                    - {_id: 2, x: 22}
   101                    - {_id: 3, x: 33}
   102                    - {_id: 4, x: 1}

View as plain text