applyProperties => properties (object/false)
This commit is contained in:
parent
702796a486
commit
beeb7c46c9
12
lib/dao.js
12
lib/dao.js
|
@ -94,10 +94,14 @@ DataAccessObject.applyScope = function(query) {
|
|||
};
|
||||
|
||||
DataAccessObject.applyProperties = function(data) {
|
||||
var scope = this.defaultScope(data, true) || {};
|
||||
if (typeof scope.where === 'object'
|
||||
&& this.definition.settings.applyProperties !== false) {
|
||||
setScopeValuesFromWhere(data, scope.where, this);
|
||||
var properties = this.definition.settings.properties;
|
||||
if (typeof properties === 'object') {
|
||||
util._extend(data, properties);
|
||||
} else if (properties !== false) {
|
||||
var scope = this.defaultScope(data, true) || {};
|
||||
if (typeof scope.where === 'object') {
|
||||
setScopeValuesFromWhere(data, scope.where, this);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ describe('default scope', function () {
|
|||
|
||||
Widget = db.define('Widget', Product.definition.properties, {
|
||||
base: 'Product',
|
||||
properties: { kind: 'Widget' },
|
||||
scope: { where: { kind: 'Widget' }, order: 'name' },
|
||||
scopes: { active: { where: { active: true } } },
|
||||
mongodb: { collection: 'Product' },
|
||||
|
|
Loading…
Reference in New Issue