Update the remote methods

This commit is contained in:
Raymond Feng 2013-08-16 16:44:31 -07:00
parent d5ab26509a
commit 705a1fc2c9
1 changed files with 20 additions and 0 deletions

View File

@ -231,6 +231,14 @@ DataAccessObject.upsert = DataAccessObject.updateOrCreate = function upsert(data
} }
}; };
// upsert ~ remoting attributes
DataAccessObject.upsert.shared = true;
DataAccessObject.upsert.accepts = {arg: 'data', type: 'object', http: {source: 'body'}};
DataAccessObject.upsert.returns = {arg: 'data', type: 'object', root: true};
DataAccessObject.upsert.http = [
{verb: 'put', path: '/'}
];
/** /**
* Find one record, same as `all`, limited by 1 and return object, not collection, * Find one record, same as `all`, limited by 1 and return object, not collection,
* if not found, create using data provided as second argument * if not found, create using data provided as second argument
@ -280,6 +288,10 @@ DataAccessObject.exists.shared = true;
DataAccessObject.exists.accepts = {arg: 'id', type: 'any'}; DataAccessObject.exists.accepts = {arg: 'id', type: 'any'};
DataAccessObject.exists.returns = {arg: 'exists', type: 'any'}; DataAccessObject.exists.returns = {arg: 'exists', type: 'any'};
DataAccessObject.exists.http = [
{verb: 'get', path: '/exists'}
];
/** /**
* Find object by id * Find object by id
* *
@ -452,6 +464,10 @@ DataAccessObject.findOne.shared = true;
DataAccessObject.findOne.accepts = {arg: 'filter', type: 'object'}; DataAccessObject.findOne.accepts = {arg: 'filter', type: 'object'};
DataAccessObject.findOne.returns = {arg: 'data', type: 'object', root: true}; DataAccessObject.findOne.returns = {arg: 'data', type: 'object', root: true};
DataAccessObject.findOne.http = [
{verb: 'get', path: '/findOne'}
];
/** /**
* Destroy all records * Destroy all records
* @param {Function} cb - callback called with (err) * @param {Function} cb - callback called with (err)
@ -591,12 +607,14 @@ DataAccessObject.prototype.save = function (options, callback) {
} }
}; };
/*
// save ~ remoting attributes // save ~ remoting attributes
DataAccessObject.prototype.save.shared = true; DataAccessObject.prototype.save.shared = true;
DataAccessObject.prototype.save.returns = {arg: 'obj', type: 'object', root: true}; DataAccessObject.prototype.save.returns = {arg: 'obj', type: 'object', root: true};
DataAccessObject.prototype.save.http = [ DataAccessObject.prototype.save.http = [
{verb: 'put', path: '/'} {verb: 'put', path: '/'}
]; ];
*/
DataAccessObject.prototype.isNewRecord = function () { DataAccessObject.prototype.isNewRecord = function () {
return !getIdValue(this.constructor, this); return !getIdValue(this.constructor, this);
@ -632,11 +650,13 @@ DataAccessObject.prototype.destroy = function (cb) {
}); });
}; };
/*
// destroy ~ remoting attributes // destroy ~ remoting attributes
DataAccessObject.prototype.destroy.shared = true; DataAccessObject.prototype.destroy.shared = true;
DataAccessObject.prototype.destroy.http = [ DataAccessObject.prototype.destroy.http = [
{verb: 'del', path: '/'} {verb: 'del', path: '/'}
]; ];
*/
/** /**
* Update single attribute * Update single attribute