db.books._parseUpdate
|
function (query, obj, upsert, multi) {
|
if (!query)
|
throw Error("need a query");
|
if (!obj)
|
throw Error("need an object");
|
|
var wc = undefined;
|
var collation = undefined;
|
var arrayFilters = undefined;
|
// can pass options via object for improved readability
|
if (typeof(upsert) === "object") {
|
if (multi) {
|
throw Error("Fourth argument must be empty when specifying " +
|
"upsert and multi with an object.");
|
}
|
|
var opts = upsert;
|
multi = opts.multi;
|
wc = opts.writeConcern;
|
upsert = opts.upsert;
|
collation = opts.collation;
|
arrayFilters = opts.arrayFilters;
|
}
|
|
// Normalize 'upsert' and 'multi' to booleans.
|
upsert = upsert ? true : false;
|
multi = multi ? true : false;
|
|
if (!wc) {
|
wc = this.getWriteConcern();
|
}
|
|
return {
|
"query": query,
|
"obj": obj,
|
"upsert": upsert,
|
"multi": multi,
|
"wc": wc,
|
"collation": collation,
|
"arrayFilters": arrayFilters
|
};
|
}
|