Permalink
Browse files

Return name of type

  • Loading branch information...
1 parent 7be5bd9 commit 08cc5eb105a8b438d8ce782a846b188a4f7cfd1b @1602 committed Jan 18, 2012
Showing with 18 additions and 0 deletions.
  1. +9 −0 lib/abstract-class.js
  2. +9 −0 test/common_test.js
View
@@ -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
@@ -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);

0 comments on commit 08cc5eb

Please sign in to comment.