lib/op.js
function() {
      var adds = null;
      var removes = null;
      var self = this;
      var idToPointer = function(id) {
        return { __type: 'Pointer',
                 className: self._targetClassName,
                 objectId: id };
      };
      var pointers = null;
      if (this.relationsToAdd.length > 0) {
        pointers = _.map(this.relationsToAdd, idToPointer);
        adds = { "__op": "AddRelation", "objects": pointers };
      }

      if (this.relationsToRemove.length > 0) {
        pointers = _.map(this.relationsToRemove, idToPointer);
        removes = { "__op": "RemoveRelation", "objects": pointers };
      }

      if (adds && removes) {
        return { "__op": "Batch", "ops": [adds, removes]};
      }

      return adds || removes || {};
    }
function() {
      var adds = null;
      var removes = null;
      var self = this;
      var idToPointer = function(id) {
        return { __type: 'Pointer',
                 className: self._targetClassName,
                 objectId: id };
      };
      var pointers = null;
      if (this.relationsToAdd.length > 0) {
        pointers = _.map(this.relationsToAdd, idToPointer);
        adds = { "__op": "AddRelation", "objects": pointers };
      }

      if (this.relationsToRemove.length > 0) {
        pointers = _.map(this.relationsToRemove, idToPointer);
        removes = { "__op": "RemoveRelation", "objects": pointers };
      }

      if (adds && removes) {
        return { "__op": "Batch", "ops": [adds, removes]};
      }

      return adds || removes || {};
    }
function ( ) { var adds = null ; var removes = null ; var self = this ; var idToPointer = function ( id ) { return { __type : 'Pointer' , className : self . _targetClassName , objectId : id } ; } ; var pointers = null ; if ( this . relationsToAdd . length > 0 ) { pointers = _ . map ( this . relationsToAdd , idToPointer ) ; adds = { "__op" : "AddRelation" , "objects" : pointers } ; } if ( this . relationsToRemove . length > 0 ) { pointers = _ . map ( this . relationsToRemove , idToPointer ) ; removes = { "__op" : "RemoveRelation" , "objects" : pointers } ; } if ( adds && removes ) { return { "__op" : "Batch" , "ops" : [ adds , removes ] } ; } return adds || removes || { } ; }
Returns a JSON version of the operation suitable for sending to Parse.
@return {Object}
Returns a JSON version of the operation suitable for sending to Parse .