Slide 37
Slide 37 text
3b. Do add helpers to eliminate user errors and
boilerplate on commonly-used code paths.
MongoDB "insert" command
try db.runCommand(
[
"insert": "cats",
"documents": [
["name": "Chester"],
["name": "Roscoe"]
],
"writeConcern": ["w": "majority"]
]
)
var opts = InsertManyOptions()
opts.writeConcern =
try WriteConcern(w: .majority)
let cats = db.collection("cats")
try cats.insertMany(
[
["name": "Chester"],
["name": "Roscoe"]
],
options: opts
)