...

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

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

     1{
     2  "description": "findOneAndReplace-let",
     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        },
    36        {
    37          "_id": 2
    38        }
    39      ]
    40    }
    41  ],
    42  "tests": [
    43    {
    44      "description": "findOneAndReplace with let option",
    45      "runOnRequirements": [
    46        {
    47          "minServerVersion": "5.0"
    48        }
    49      ],
    50      "operations": [
    51        {
    52          "name": "findOneAndReplace",
    53          "object": "collection0",
    54          "arguments": {
    55            "filter": {
    56              "$expr": {
    57                "$eq": [
    58                  "$_id",
    59                  "$$id"
    60                ]
    61              }
    62            },
    63            "replacement": {
    64              "x": "x"
    65            },
    66            "let": {
    67              "id": 1
    68            }
    69          },
    70          "expectResult": {
    71            "_id": 1
    72          }
    73        }
    74      ],
    75      "expectEvents": [
    76        {
    77          "client": "client0",
    78          "events": [
    79            {
    80              "commandStartedEvent": {
    81                "command": {
    82                  "findAndModify": "coll0",
    83                  "query": {
    84                    "$expr": {
    85                      "$eq": [
    86                        "$_id",
    87                        "$$id"
    88                      ]
    89                    }
    90                  },
    91                  "update": {
    92                    "x": "x"
    93                  },
    94                  "let": {
    95                    "id": 1
    96                  }
    97                }
    98              }
    99            }
   100          ]
   101        }
   102      ],
   103      "outcome": [
   104        {
   105          "collectionName": "coll0",
   106          "databaseName": "crud-tests",
   107          "documents": [
   108            {
   109              "_id": 1,
   110              "x": "x"
   111            },
   112            {
   113              "_id": 2
   114            }
   115          ]
   116        }
   117      ]
   118    },
   119    {
   120      "description": "findOneAndReplace with let option unsupported (server-side error)",
   121      "runOnRequirements": [
   122        {
   123          "minServerVersion": "4.2.0",
   124          "maxServerVersion": "4.4.99"
   125        }
   126      ],
   127      "operations": [
   128        {
   129          "name": "findOneAndReplace",
   130          "object": "collection0",
   131          "arguments": {
   132            "filter": {
   133              "$expr": {
   134                "$eq": [
   135                  "$_id",
   136                  "$$id"
   137                ]
   138              }
   139            },
   140            "replacement": {
   141              "x": "x"
   142            },
   143            "let": {
   144              "id": 1
   145            }
   146          },
   147          "expectError": {
   148            "errorContains": "field 'let' is an unknown field",
   149            "isClientError": false
   150          }
   151        }
   152      ],
   153      "expectEvents": [
   154        {
   155          "client": "client0",
   156          "events": [
   157            {
   158              "commandStartedEvent": {
   159                "command": {
   160                  "findAndModify": "coll0",
   161                  "query": {
   162                    "$expr": {
   163                      "$eq": [
   164                        "$_id",
   165                        "$$id"
   166                      ]
   167                    }
   168                  },
   169                  "update": {
   170                    "x": "x"
   171                  },
   172                  "let": {
   173                    "id": 1
   174                  }
   175                }
   176              }
   177            }
   178          ]
   179        }
   180      ],
   181      "outcome": [
   182        {
   183          "collectionName": "coll0",
   184          "databaseName": "crud-tests",
   185          "documents": [
   186            {
   187              "_id": 1
   188            },
   189            {
   190              "_id": 2
   191            }
   192          ]
   193        }
   194      ]
   195    }
   196  ]
   197}

View as plain text