Return name of type

This commit is contained in:
Anatoliy Chakkaev 2012-01-18 19:20:05 +04:00
parent 7be5bd93fb
commit 08cc5eb105
2 changed files with 18 additions and 0 deletions

View File

@ -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)

View File

@ -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);