diff --git a/lib/model-definition.js b/lib/model-definition.js index ae53a1be..32bbcd1c 100644 --- a/lib/model-definition.js +++ b/lib/model-definition.js @@ -210,6 +210,7 @@ ModelDefinition.prototype.build = function (forceRebuild) { this.properties = null; this.relations = []; this._ids = null; + this.json = null; } if (this.properties) { return this.properties; diff --git a/test/model-definition.test.js b/test/model-definition.test.js index 080685e4..e7f22ff1 100644 --- a/test/model-definition.test.js +++ b/test/model-definition.test.js @@ -55,6 +55,8 @@ describe('ModelDefinition class', function () { }); User.build(); + + var json = User.toJSON(); User.defineProperty("id", {type: "number", id: true}); assert.equal(User.properties.name.type, String); @@ -62,8 +64,12 @@ describe('ModelDefinition class', function () { assert.equal(User.properties.approved.type, Boolean); assert.equal(User.properties.joinedAt.type, Date); assert.equal(User.properties.age.type, Number); - + assert.equal(User.properties.id.type, Number); + + json = User.toJSON(); + assert.deepEqual(json.properties.id, {type: 'Number', id: true}); + done(); });