update: function()

in public/dexie.js [3188:3210]


      update: function (keyOrObject, modifications) {
        if (typeof modifications !== "object" || isArray(modifications))
          throw new exceptions.InvalidArgument(
            "Modifications must be an object."
          );
        if (typeof keyOrObject === "object" && !isArray(keyOrObject)) {
          // object to modify. Also modify given object with the modifications:
          keys(modifications).forEach(function (keyPath) {
            setByKeyPath(keyOrObject, keyPath, modifications[keyPath]);
          });
          var key = getByKeyPath(keyOrObject, this.schema.primKey.keyPath);
          if (key === undefined)
            return rejection(
              new exceptions.InvalidArgument(
                "Given object does not contain its primary key"
              )
            );
          return this.where(":id").equals(key).modify(modifications);
        } else {
          // key to modify
          return this.where(":id").equals(keyOrObject).modify(modifications);
        }
      },