Skip to content

Instantly share code, notes, and snippets.

@kevinAlbs
Last active April 27, 2019 00:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinAlbs/ff46583454de0308964fda7fce733803 to your computer and use it in GitHub Desktop.
Save kevinAlbs/ff46583454de0308964fda7fce733803 to your computer and use it in GitHub Desktop.
mongocryptd returns upsert/multi as false
/*
* start mongocryptd, then do:
* mongo --port 27017 repro.js
*/
var schema = {
properties: {
ssn: {
encrypt: {
keyId: [
BinData(4, "AAAAAAAAAAAAAAAAAAAAAA==")
],
bsonType: "string",
algorithm: "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic",
initializationVector: BinData(0, "aWlpaWlpaWlpaWlpaWlpaQ==")
}
}
},
bsonType: "object"
};
var cmd = {
update: "coll",
updates: [{ q: {}, u: { ssn: "123" }, upsert: true, multi: true }],
jsonSchema: schema
};
printjson(db.runCommand(cmd))
/* Prints:
{
"hasEncryptionPlaceholders" : true,
"schemaRequiresEncryption" : true,
"result" : {
"update" : "coll",
"updates" : [
{
"q" : {
},
"u" : {
"ssn" : BinData(6,"AEkAAAAQYQABAAAABWl2ABAAAAAAaWlpaWlpaWlpaWlpaWlpaQVraQAQAAAABAAAAAAAAAAAAAAAAAAAAAACdgAEAAAAMTIzAAA=")
},
"multi" : false,
"upsert" : false
}
],
"$db" : "test"
},
"ok" : 1
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment