Add root true to remote methods
This commit is contained in:
parent
93dd0eb287
commit
5bf2d1ff23
17
lib/dao.js
17
lib/dao.js
|
@ -165,7 +165,7 @@ DataAccessObject.create = function (data, callback) {
|
|||
|
||||
DataAccessObject.create.shared = true;
|
||||
DataAccessObject.create.accepts = {arg: 'data', type: 'object', http: {source: 'body'}};
|
||||
DataAccessObject.create.returns = {arg: 'data', type: 'object'};
|
||||
DataAccessObject.create.returns = {arg: 'data', type: 'object', root: true};
|
||||
DataAccessObject.create.http = {verb: 'post', path: '/'};
|
||||
|
||||
function stillConnecting(dataSource, obj, args) {
|
||||
|
@ -262,6 +262,7 @@ DataAccessObject.exists = function exists(id, cb) {
|
|||
// exists ~ remoting attributes
|
||||
DataAccessObject.exists.shared = true;
|
||||
DataAccessObject.exists.accepts = {arg: 'id', type: 'any'};
|
||||
DataAccessObject.exists.returns = {arg: 'exists', type: 'any'};
|
||||
|
||||
/**
|
||||
* Find object by id
|
||||
|
@ -289,6 +290,9 @@ DataAccessObject.findById = function find(id, cb) {
|
|||
DataAccessObject.findById.accepts = [
|
||||
{arg: 'id', type: 'any'}
|
||||
];
|
||||
DataAccessObject.findById.returns = [
|
||||
{arg: 'data', type: 'any', root: true}
|
||||
];
|
||||
DataAccessObject.findById.shared = true;
|
||||
DataAccessObject.findById.http = [
|
||||
{verb: 'get', path: '/:id'}
|
||||
|
@ -402,6 +406,7 @@ DataAccessObject.find = function find(params, cb) {
|
|||
|
||||
// all ~ remoting attributes
|
||||
DataAccessObject.find.accepts = {arg: 'filter', type: 'object'};
|
||||
DataAccessObject.find.returns = {arg: 'data', type: 'array', root: true};
|
||||
DataAccessObject.find.shared = true;
|
||||
DataAccessObject.find.http = [
|
||||
{verb: 'get', path: '/'}
|
||||
|
@ -429,7 +434,7 @@ DataAccessObject.findOne = function findOne(params, cb) {
|
|||
|
||||
DataAccessObject.findOne.shared = true;
|
||||
DataAccessObject.findOne.accepts = {arg: 'filter', type: 'object'};
|
||||
DataAccessObject.findOne.returns = {arg: 'data', type: 'object'};
|
||||
DataAccessObject.findOne.returns = {arg: 'data', type: 'object', root: true};
|
||||
|
||||
/**
|
||||
* Destroy all records
|
||||
|
@ -493,6 +498,9 @@ DataAccessObject.count.shared = true;
|
|||
DataAccessObject.count.accepts = [
|
||||
{arg: 'where', type: 'object'}
|
||||
];
|
||||
DataAccessObject.count.returns = [
|
||||
{arg: 'count', type: 'number'}
|
||||
];
|
||||
DataAccessObject.count.http = {verb: 'get', path: '/count'};
|
||||
|
||||
/**
|
||||
|
@ -568,7 +576,7 @@ DataAccessObject.prototype.save = function (options, callback) {
|
|||
|
||||
// save ~ remoting attributes
|
||||
DataAccessObject.prototype.save.shared = true;
|
||||
DataAccessObject.prototype.save.returns = {arg: 'obj', type: 'object'};
|
||||
DataAccessObject.prototype.save.returns = {arg: 'obj', type: 'object', root: true};
|
||||
DataAccessObject.prototype.save.http = [
|
||||
{verb: 'put', path: '/'}
|
||||
];
|
||||
|
@ -692,6 +700,7 @@ DataAccessObject.prototype.updateAttributes = function updateAttributes(data, cb
|
|||
// updateAttributes ~ remoting attributes
|
||||
DataAccessObject.prototype.updateAttributes.shared = true;
|
||||
DataAccessObject.prototype.updateAttributes.accepts = {arg: 'data', type: 'object', http: {source: 'body'}};
|
||||
DataAccessObject.prototype.updateAttributes.returns = {arg: 'data', type: 'object', root: true};
|
||||
DataAccessObject.prototype.updateAttributes.http = [
|
||||
{verb: 'put', path: '/'}
|
||||
];
|
||||
|
@ -709,7 +718,7 @@ DataAccessObject.prototype.reload = function reload(callback) {
|
|||
};
|
||||
|
||||
DataAccessObject.prototype.reload.shared = true;
|
||||
DataAccessObject.prototype.reload.returns = {arg: 'data', type: 'object'};
|
||||
DataAccessObject.prototype.reload.returns = {arg: 'data', type: 'object', root: true};
|
||||
|
||||
/**
|
||||
* Define readonly property on object
|
||||
|
|
|
@ -93,6 +93,8 @@ function DataSource(name, settings) {
|
|||
var fn = this.DataAccessObject.prototype[name];
|
||||
|
||||
if(typeof fn === 'function') {
|
||||
var returns = fn.returns;
|
||||
|
||||
this.defineOperation(name, {
|
||||
prototype: true,
|
||||
accepts: fn.accepts,
|
||||
|
|
Loading…
Reference in New Issue