code: function(json, respond, promisesSofar, rpcSession) {
      return models.findById(json._id).then(function(obj) {
        if (!obj) {
          return new jsonrpc.JsonRpcError(-32001, 'Unable to find object to delete');
        }
        var deleted = new models.Deleted();
        deleted.set({
          deletedId: obj._id,
          object: obj,
          by: rpcSession.httpRequest.user.id
        });
        return deleted.save().then(function(doc) {
          obj.remove();
          return { _id: deleted._id };
        });
      });
    }
docs: /*
  this doesn't work because getIndexes isn't working plus it doesn't handle embedded arrays
  cloneObject: function(json, respond, promisesSofar, rpcSession) {
  return models.findById(json._id).then(function(obj) {
  if (!obj) {
  return new jsonrpc.JsonRpcError(-32001, 'Unable to find object to clone');
  }
  var model = getModelFromId(obj._id);
  if (!model) {
  return new jsonrpc.JsonRpcError(-32001, 'Unable to find model for object');
  }
  var clone = new model();
  model.collection.getIndexes(function(indexes) {
  if (!indexes) {
  return;
  }
  indexes.forEach((index) => {
  if (index.options.unique) {
  XXX what if key is not a string?
  Object.keys(index.key).forEach( k => obj.set(k, obj.get(k) + '1'));
  };
  });
  });
  delete obj._id;
  clone.set(obj);
  return clone.save().then(function(doc) {
  return { _id: clone._id };
  });
  });
  },
   XXX revert to async version