Return name of type
This commit is contained in:
parent
7be5bd93fb
commit
08cc5eb105
|
@ -100,6 +100,15 @@ AbstractClass.defineProperty = function (prop, params) {
|
|||
this.schema.defineProperty(this.modelName, prop, params);
|
||||
};
|
||||
|
||||
AbstractClass.whatTypeName = function (propName) {
|
||||
var ds = this.schema.definitions[this.modelName];
|
||||
return ds.properties[propName].type.name;
|
||||
};
|
||||
|
||||
AbstractClass.prototype.whatTypeName = function (propName) {
|
||||
return this.constructor.whatTypeName(propName);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param data [optional]
|
||||
* @param callback(err, obj)
|
||||
|
|
|
@ -415,6 +415,15 @@ function testOrm(schema) {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return type of property', function (test) {
|
||||
test.equal(Post.whatTypeName('title'), 'String');
|
||||
test.equal(Post.whatTypeName('content'), 'Text');
|
||||
var p = new Post;
|
||||
test.equal(p.whatTypeName('title'), 'String');
|
||||
test.equal(p.whatTypeName('content'), 'Text');
|
||||
test.done();
|
||||
});
|
||||
|
||||
function allTestsDone() {
|
||||
schema.disconnect();
|
||||
console.log('Test done in %dms\n', Date.now() - start);
|
||||
|
|
Loading…
Reference in New Issue