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