...

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

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

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

View as plain text