Update remoting signatures for dao.

This commit is contained in:
Ritchie Martori 2013-05-24 15:10:34 -07:00
parent 0a8df17135
commit 50b2036511
2 changed files with 16 additions and 15 deletions

View File

@ -267,6 +267,15 @@ DataAccessObject.find = function find(id, cb) {
}.bind(this));
};
// find ~ remoting attributes
DataAccessObject.find.accepts = [
{arg: 'id', type: 'number'}
];
DataAccessObject.find.shared = true;
DataAccessObject.find.http = [
{verb: 'get', path: '/:id'}
];
/**
* Find all instances of Model, matched by query
* make sure you have marked as `index: true` fields for filter or sort
@ -341,18 +350,6 @@ DataAccessObject.findOne = function findOne(params, cb) {
});
};
// findOne ~ remoting attributes
DataAccessObject.findOne.accepts = [
{arg: 'id', type: 'number', optional: true},
{arg: 'filter', type: 'object', optional: true}
];
DataAccessObject.findOne.shared = true;
DataAccessObject.findOne.http = [
{verb: 'get', path: '/findOne'},
{verb: 'get', path: '/find-one'},
{verb: 'get', path: '/:id'}
];
/**
* Destroy all records
* @param {Function} cb - callback called with (err)
@ -387,7 +384,7 @@ DataAccessObject.count = function (where, cb) {
// count ~ remoting attributes
DataAccessObject.count.shared = true;
DataAccessObject.count.accepts = [
{arg: 'where', type: 'object', optional: true}
{arg: 'where', type: 'object'}
];
DataAccessObject.count.http = {verb: 'get', path: '/count'};
@ -467,7 +464,7 @@ DataAccessObject.prototype.save.shared = true;
DataAccessObject.prototype.save.returns = {arg: 'obj', type: 'object'};
DataAccessObject.prototype.save.http = [
{verb: 'post', path: '/'},
{verb: 'put', path: '/:id'}
{verb: 'put', path: '/'}
];
DataAccessObject.prototype.isNewRecord = function () {

View File

@ -243,6 +243,7 @@ DataSource.prototype.mixin = function (ModelCtor) {
DataSource.prototype.attach = function (ModelCtor) {
var properties = ModelCtor.schema.definitions[ModelCtor.modelName].properties;
var settings = ModelCtor.schema.definitions[ModelCtor.modelName].settings;
var className = ModelCtor.modelName;
this.mixin(ModelCtor);
@ -259,11 +260,13 @@ DataSource.prototype.attach = function (ModelCtor) {
hiddenProperty(ModelCtor, 'schema', this);
// add to def
this.definitions[ModelCtor.modelName] = {
this.definitions[className] = {
properties: properties,
settings: settings
};
this.models[className] = ModelCtor;
return this;
}
@ -632,6 +635,7 @@ DataSource.prototype.defineForeignKey = function defineForeignKey(className, key
} else {
this.definitions[className].properties[key] = {type: Number};
}
this.models[className].registerProperty(key);
};