...

Text file src/go.mongodb.org/mongo-driver/testdata/crud/v1/write/bulkWrite.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  "minServerVersion": "2.6",
    13  "tests": [
    14    {
    15      "description": "BulkWrite with deleteOne operations",
    16      "operation": {
    17        "name": "bulkWrite",
    18        "arguments": {
    19          "requests": [
    20            {
    21              "name": "deleteOne",
    22              "arguments": {
    23                "filter": {
    24                  "_id": 3
    25                }
    26              }
    27            },
    28            {
    29              "name": "deleteOne",
    30              "arguments": {
    31                "filter": {
    32                  "_id": 2
    33                }
    34              }
    35            }
    36          ],
    37          "options": {
    38            "ordered": true
    39          }
    40        }
    41      },
    42      "outcome": {
    43        "result": {
    44          "deletedCount": 1,
    45          "insertedCount": 0,
    46          "insertedIds": {},
    47          "matchedCount": 0,
    48          "modifiedCount": 0,
    49          "upsertedCount": 0,
    50          "upsertedIds": {}
    51        },
    52        "collection": {
    53          "data": [
    54            {
    55              "_id": 1,
    56              "x": 11
    57            }
    58          ]
    59        }
    60      }
    61    },
    62    {
    63      "description": "BulkWrite with deleteMany operations",
    64      "operation": {
    65        "name": "bulkWrite",
    66        "arguments": {
    67          "requests": [
    68            {
    69              "name": "deleteMany",
    70              "arguments": {
    71                "filter": {
    72                  "x": {
    73                    "$lt": 11
    74                  }
    75                }
    76              }
    77            },
    78            {
    79              "name": "deleteMany",
    80              "arguments": {
    81                "filter": {
    82                  "x": {
    83                    "$lte": 22
    84                  }
    85                }
    86              }
    87            }
    88          ],
    89          "options": {
    90            "ordered": true
    91          }
    92        }
    93      },
    94      "outcome": {
    95        "result": {
    96          "deletedCount": 2,
    97          "insertedCount": 0,
    98          "insertedIds": {},
    99          "matchedCount": 0,
   100          "modifiedCount": 0,
   101          "upsertedCount": 0,
   102          "upsertedIds": {}
   103        },
   104        "collection": {
   105          "data": []
   106        }
   107      }
   108    },
   109    {
   110      "description": "BulkWrite with insertOne operations",
   111      "operation": {
   112        "name": "bulkWrite",
   113        "arguments": {
   114          "requests": [
   115            {
   116              "name": "insertOne",
   117              "arguments": {
   118                "document": {
   119                  "_id": 3,
   120                  "x": 33
   121                }
   122              }
   123            },
   124            {
   125              "name": "insertOne",
   126              "arguments": {
   127                "document": {
   128                  "_id": 4,
   129                  "x": 44
   130                }
   131              }
   132            }
   133          ],
   134          "options": {
   135            "ordered": true
   136          }
   137        }
   138      },
   139      "outcome": {
   140        "result": {
   141          "deletedCount": 0,
   142          "insertedCount": 2,
   143          "insertedIds": {
   144            "0": 3,
   145            "1": 4
   146          },
   147          "matchedCount": 0,
   148          "modifiedCount": 0,
   149          "upsertedCount": 0,
   150          "upsertedIds": {}
   151        },
   152        "collection": {
   153          "data": [
   154            {
   155              "_id": 1,
   156              "x": 11
   157            },
   158            {
   159              "_id": 2,
   160              "x": 22
   161            },
   162            {
   163              "_id": 3,
   164              "x": 33
   165            },
   166            {
   167              "_id": 4,
   168              "x": 44
   169            }
   170          ]
   171        }
   172      }
   173    },
   174    {
   175      "description": "BulkWrite with replaceOne operations",
   176      "operation": {
   177        "name": "bulkWrite",
   178        "arguments": {
   179          "requests": [
   180            {
   181              "name": "replaceOne",
   182              "arguments": {
   183                "filter": {
   184                  "_id": 3
   185                },
   186                "replacement": {
   187                  "x": 33
   188                }
   189              }
   190            },
   191            {
   192              "name": "replaceOne",
   193              "arguments": {
   194                "filter": {
   195                  "_id": 1
   196                },
   197                "replacement": {
   198                  "x": 12
   199                }
   200              }
   201            },
   202            {
   203              "name": "replaceOne",
   204              "arguments": {
   205                "filter": {
   206                  "_id": 3
   207                },
   208                "replacement": {
   209                  "x": 33
   210                },
   211                "upsert": true
   212              }
   213            }
   214          ],
   215          "options": {
   216            "ordered": true
   217          }
   218        }
   219      },
   220      "outcome": {
   221        "result": {
   222          "deletedCount": 0,
   223          "insertedCount": 0,
   224          "insertedIds": {},
   225          "matchedCount": 1,
   226          "modifiedCount": 1,
   227          "upsertedCount": 1,
   228          "upsertedIds": {
   229            "2": 3
   230          }
   231        },
   232        "collection": {
   233          "data": [
   234            {
   235              "_id": 1,
   236              "x": 12
   237            },
   238            {
   239              "_id": 2,
   240              "x": 22
   241            },
   242            {
   243              "_id": 3,
   244              "x": 33
   245            }
   246          ]
   247        }
   248      }
   249    },
   250    {
   251      "description": "BulkWrite with updateOne operations",
   252      "operation": {
   253        "name": "bulkWrite",
   254        "arguments": {
   255          "requests": [
   256            {
   257              "name": "updateOne",
   258              "arguments": {
   259                "filter": {
   260                  "_id": 0
   261                },
   262                "update": {
   263                  "$set": {
   264                    "x": 0
   265                  }
   266                }
   267              }
   268            },
   269            {
   270              "name": "updateOne",
   271              "arguments": {
   272                "filter": {
   273                  "_id": 1
   274                },
   275                "update": {
   276                  "$set": {
   277                    "x": 11
   278                  }
   279                }
   280              }
   281            },
   282            {
   283              "name": "updateOne",
   284              "arguments": {
   285                "filter": {
   286                  "_id": 2
   287                },
   288                "update": {
   289                  "$inc": {
   290                    "x": 1
   291                  }
   292                }
   293              }
   294            },
   295            {
   296              "name": "updateOne",
   297              "arguments": {
   298                "filter": {
   299                  "_id": 3
   300                },
   301                "update": {
   302                  "$set": {
   303                    "x": 33
   304                  }
   305                },
   306                "upsert": true
   307              }
   308            }
   309          ],
   310          "options": {
   311            "ordered": true
   312          }
   313        }
   314      },
   315      "outcome": {
   316        "result": {
   317          "deletedCount": 0,
   318          "insertedCount": 0,
   319          "insertedIds": {},
   320          "matchedCount": 2,
   321          "modifiedCount": 1,
   322          "upsertedCount": 1,
   323          "upsertedIds": {
   324            "3": 3
   325          }
   326        },
   327        "collection": {
   328          "data": [
   329            {
   330              "_id": 1,
   331              "x": 11
   332            },
   333            {
   334              "_id": 2,
   335              "x": 23
   336            },
   337            {
   338              "_id": 3,
   339              "x": 33
   340            }
   341          ]
   342        }
   343      }
   344    },
   345    {
   346      "description": "BulkWrite with updateMany operations",
   347      "operation": {
   348        "name": "bulkWrite",
   349        "arguments": {
   350          "requests": [
   351            {
   352              "name": "updateMany",
   353              "arguments": {
   354                "filter": {
   355                  "x": {
   356                    "$lt": 11
   357                  }
   358                },
   359                "update": {
   360                  "$set": {
   361                    "x": 0
   362                  }
   363                }
   364              }
   365            },
   366            {
   367              "name": "updateMany",
   368              "arguments": {
   369                "filter": {
   370                  "x": {
   371                    "$lte": 22
   372                  }
   373                },
   374                "update": {
   375                  "$unset": {
   376                    "y": 1
   377                  }
   378                }
   379              }
   380            },
   381            {
   382              "name": "updateMany",
   383              "arguments": {
   384                "filter": {
   385                  "x": {
   386                    "$lte": 22
   387                  }
   388                },
   389                "update": {
   390                  "$inc": {
   391                    "x": 1
   392                  }
   393                }
   394              }
   395            },
   396            {
   397              "name": "updateMany",
   398              "arguments": {
   399                "filter": {
   400                  "_id": 3
   401                },
   402                "update": {
   403                  "$set": {
   404                    "x": 33
   405                  }
   406                },
   407                "upsert": true
   408              }
   409            }
   410          ],
   411          "options": {
   412            "ordered": true
   413          }
   414        }
   415      },
   416      "outcome": {
   417        "result": {
   418          "deletedCount": 0,
   419          "insertedCount": 0,
   420          "insertedIds": {},
   421          "matchedCount": 4,
   422          "modifiedCount": 2,
   423          "upsertedCount": 1,
   424          "upsertedIds": {
   425            "3": 3
   426          }
   427        },
   428        "collection": {
   429          "data": [
   430            {
   431              "_id": 1,
   432              "x": 12
   433            },
   434            {
   435              "_id": 2,
   436              "x": 23
   437            },
   438            {
   439              "_id": 3,
   440              "x": 33
   441            }
   442          ]
   443        }
   444      }
   445    },
   446    {
   447      "description": "BulkWrite with mixed ordered operations",
   448      "operation": {
   449        "name": "bulkWrite",
   450        "arguments": {
   451          "requests": [
   452            {
   453              "name": "insertOne",
   454              "arguments": {
   455                "document": {
   456                  "_id": 3,
   457                  "x": 33
   458                }
   459              }
   460            },
   461            {
   462              "name": "updateOne",
   463              "arguments": {
   464                "filter": {
   465                  "_id": 2
   466                },
   467                "update": {
   468                  "$inc": {
   469                    "x": 1
   470                  }
   471                }
   472              }
   473            },
   474            {
   475              "name": "updateMany",
   476              "arguments": {
   477                "filter": {
   478                  "_id": {
   479                    "$gt": 1
   480                  }
   481                },
   482                "update": {
   483                  "$inc": {
   484                    "x": 1
   485                  }
   486                }
   487              }
   488            },
   489            {
   490              "name": "insertOne",
   491              "arguments": {
   492                "document": {
   493                  "_id": 4,
   494                  "x": 44
   495                }
   496              }
   497            },
   498            {
   499              "name": "deleteMany",
   500              "arguments": {
   501                "filter": {
   502                  "x": {
   503                    "$nin": [
   504                      24,
   505                      34
   506                    ]
   507                  }
   508                }
   509              }
   510            },
   511            {
   512              "name": "replaceOne",
   513              "arguments": {
   514                "filter": {
   515                  "_id": 4
   516                },
   517                "replacement": {
   518                  "_id": 4,
   519                  "x": 44
   520                },
   521                "upsert": true
   522              }
   523            }
   524          ],
   525          "options": {
   526            "ordered": true
   527          }
   528        }
   529      },
   530      "outcome": {
   531        "result": {
   532          "deletedCount": 2,
   533          "insertedCount": 2,
   534          "insertedIds": {
   535            "0": 3,
   536            "3": 4
   537          },
   538          "matchedCount": 3,
   539          "modifiedCount": 3,
   540          "upsertedCount": 1,
   541          "upsertedIds": {
   542            "5": 4
   543          }
   544        },
   545        "collection": {
   546          "data": [
   547            {
   548              "_id": 2,
   549              "x": 24
   550            },
   551            {
   552              "_id": 3,
   553              "x": 34
   554            },
   555            {
   556              "_id": 4,
   557              "x": 44
   558            }
   559          ]
   560        }
   561      }
   562    },
   563    {
   564      "description": "BulkWrite with mixed unordered operations",
   565      "operation": {
   566        "name": "bulkWrite",
   567        "arguments": {
   568          "requests": [
   569            {
   570              "name": "replaceOne",
   571              "arguments": {
   572                "filter": {
   573                  "_id": 3
   574                },
   575                "replacement": {
   576                  "_id": 3,
   577                  "x": 33
   578                },
   579                "upsert": true
   580              }
   581            },
   582            {
   583              "name": "deleteOne",
   584              "arguments": {
   585                "filter": {
   586                  "_id": 1
   587                }
   588              }
   589            },
   590            {
   591              "name": "updateOne",
   592              "arguments": {
   593                "filter": {
   594                  "_id": 2
   595                },
   596                "update": {
   597                  "$inc": {
   598                    "x": 1
   599                  }
   600                }
   601              }
   602            }
   603          ],
   604          "options": {
   605            "ordered": false
   606          }
   607        }
   608      },
   609      "outcome": {
   610        "result": {
   611          "deletedCount": 1,
   612          "insertedCount": 0,
   613          "insertedIds": {},
   614          "matchedCount": 1,
   615          "modifiedCount": 1,
   616          "upsertedCount": 1,
   617          "upsertedIds": {
   618            "0": 3
   619          }
   620        },
   621        "collection": {
   622          "data": [
   623            {
   624              "_id": 2,
   625              "x": 23
   626            },
   627            {
   628              "_id": 3,
   629              "x": 33
   630            }
   631          ]
   632        }
   633      }
   634    },
   635    {
   636      "description": "BulkWrite continue-on-error behavior with unordered (preexisting duplicate key)",
   637      "operation": {
   638        "name": "bulkWrite",
   639        "arguments": {
   640          "requests": [
   641            {
   642              "name": "insertOne",
   643              "arguments": {
   644                "document": {
   645                  "_id": 2,
   646                  "x": 22
   647                }
   648              }
   649            },
   650            {
   651              "name": "insertOne",
   652              "arguments": {
   653                "document": {
   654                  "_id": 3,
   655                  "x": 33
   656                }
   657              }
   658            },
   659            {
   660              "name": "insertOne",
   661              "arguments": {
   662                "document": {
   663                  "_id": 4,
   664                  "x": 44
   665                }
   666              }
   667            }
   668          ],
   669          "options": {
   670            "ordered": false
   671          }
   672        }
   673      },
   674      "outcome": {
   675        "error": true,
   676        "result": {
   677          "deletedCount": 0,
   678          "insertedCount": 2,
   679          "matchedCount": 0,
   680          "modifiedCount": 0,
   681          "upsertedCount": 0,
   682          "upsertedIds": {}
   683        },
   684        "collection": {
   685          "data": [
   686            {
   687              "_id": 1,
   688              "x": 11
   689            },
   690            {
   691              "_id": 2,
   692              "x": 22
   693            },
   694            {
   695              "_id": 3,
   696              "x": 33
   697            },
   698            {
   699              "_id": 4,
   700              "x": 44
   701            }
   702          ]
   703        }
   704      }
   705    },
   706    {
   707      "description": "BulkWrite continue-on-error behavior with unordered (duplicate key in requests)",
   708      "operation": {
   709        "name": "bulkWrite",
   710        "arguments": {
   711          "requests": [
   712            {
   713              "name": "insertOne",
   714              "arguments": {
   715                "document": {
   716                  "_id": 3,
   717                  "x": 33
   718                }
   719              }
   720            },
   721            {
   722              "name": "insertOne",
   723              "arguments": {
   724                "document": {
   725                  "_id": 3,
   726                  "x": 33
   727                }
   728              }
   729            },
   730            {
   731              "name": "insertOne",
   732              "arguments": {
   733                "document": {
   734                  "_id": 4,
   735                  "x": 44
   736                }
   737              }
   738            }
   739          ],
   740          "options": {
   741            "ordered": false
   742          }
   743        }
   744      },
   745      "outcome": {
   746        "error": true,
   747        "result": {
   748          "deletedCount": 0,
   749          "insertedCount": 2,
   750          "matchedCount": 0,
   751          "modifiedCount": 0,
   752          "upsertedCount": 0,
   753          "upsertedIds": {}
   754        },
   755        "collection": {
   756          "data": [
   757            {
   758              "_id": 1,
   759              "x": 11
   760            },
   761            {
   762              "_id": 2,
   763              "x": 22
   764            },
   765            {
   766              "_id": 3,
   767              "x": 33
   768            },
   769            {
   770              "_id": 4,
   771              "x": 44
   772            }
   773          ]
   774        }
   775      }
   776    }
   777  ]
   778}

View as plain text