From 066e87300d59b589046f557f0edf33402639a84a Mon Sep 17 00:00:00 2001 From: Jaka Hudoklin Date: Tue, 12 Aug 2014 15:03:15 +0200 Subject: [PATCH] add count to relations and scopes Signed-off-by: Jaka Hudoklin --- lib/models/model.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/models/model.js b/lib/models/model.js index 99d899b4..6694ac55 100644 --- a/lib/models/model.js +++ b/lib/models/model.js @@ -503,6 +503,13 @@ Model.scopeRemoting = function(scopeName, scope, define) { http: {verb: 'delete', path: '/' + pathName}, description: 'Deletes all ' + scopeName + ' of this model.' }); + + define('__count__' + scopeName, { + isStatic: isStatic, + http: {verb: 'get', path: '/' + pathName + '/count'}, + description: 'Counts ' + scopeName + ' of ' + this.modelName + '.', + returns: {arg: 'count', type: 'number', root: true} + }); }; Model.nestRemoting = function(relationName, options, cb) {