Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- > db.myItems.save
- function (obj, opts) {
- if (obj == null)
- throw Error("can't save a null");
- if (typeof(obj) == "number" || typeof(obj) == "string")
- throw Error("can't save a number or string");
- if (typeof(obj._id) == "undefined") {
- obj._id = new ObjectId();
- return this.insert(obj, opts);
- } else {
- return this.update({_id: obj._id}, obj, Object.merge({upsert: true}, opts));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement