@onehat/data 1.8.29 → 1.8.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -25,9 +25,9 @@ describe('Schema', function() {
|
|
|
25
25
|
expect(_.isEqual(clone._originalConfig, this.schema._originalConfig)).to.be.true;
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
it('
|
|
29
|
-
const
|
|
30
|
-
expect(_.isEqual(
|
|
28
|
+
it('getPropertyDefinition', function() {
|
|
29
|
+
const propertyDefinition = this.schema.getPropertyDefinition('groups_users__id');
|
|
30
|
+
expect(_.isEqual(propertyDefinition.name, 'groups_users__id')).to.be.true;
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
});
|
package/package.json
CHANGED
package/src/Schema/Schema.js
CHANGED
|
@@ -59,7 +59,7 @@ export default class Schema extends EventEmitter {
|
|
|
59
59
|
displayProperty: null,
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
* @member {array}
|
|
62
|
+
* @member {array} properties - Array of Property definition objects
|
|
63
63
|
*/
|
|
64
64
|
properties: [],
|
|
65
65
|
|
|
@@ -183,20 +183,20 @@ export default class Schema extends EventEmitter {
|
|
|
183
183
|
|
|
184
184
|
/**
|
|
185
185
|
* Gets a single Property definition by name,
|
|
186
|
-
* @param {string} propertyName - Name of the
|
|
187
|
-
* @return {object}
|
|
186
|
+
* @param {string} propertyName - Name of the property definition to retrieve
|
|
187
|
+
* @return {object} propertyDefinition - The property definition
|
|
188
188
|
*/
|
|
189
|
-
|
|
189
|
+
getPropertyDefinition = (propertyName) => {
|
|
190
190
|
if (this.isDestroyed) {
|
|
191
|
-
throw Error('this.
|
|
191
|
+
throw Error('this.getPropertyDefinition is no longer valid. Schema has been destroyed.');
|
|
192
192
|
}
|
|
193
|
-
const
|
|
194
|
-
propertyDefinition.name === propertyName;
|
|
193
|
+
const propertyDefinition = _.find(this.model.properties, (propertyDefinition) => {
|
|
194
|
+
return propertyDefinition.name === propertyName;
|
|
195
195
|
});
|
|
196
|
-
if (!
|
|
197
|
-
throw new Error('Property ' + propertyName + ' not found.
|
|
196
|
+
if (!propertyDefinition) {
|
|
197
|
+
throw new Error('Property definition ' + propertyName + ' not found.');
|
|
198
198
|
}
|
|
199
|
-
return
|
|
199
|
+
return propertyDefinition;
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
/**
|