From 771bf70ec520693cc5cd2afbe58845226e3621fa Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Tue, 28 May 2013 15:40:16 -0700 Subject: [PATCH] Add options including default --- lib/model-builder.js | 9 ++++++++- test/adl.test.js | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/model-builder.js b/lib/model-builder.js index 7cceeb10..b2455cbb 100644 --- a/lib/model-builder.js +++ b/lib/model-builder.js @@ -416,7 +416,14 @@ function buildSchema(name, properties, associations) { }); delete properties[p]; } else { - properties[p] = type; + var typeDef = { + type: type + }; + delete properties[p].type; + for(var a in properties[p]) { + typeDef[a] = properties[p][a]; + } + properties[p] = typeDef; } } return properties; diff --git a/test/adl.test.js b/test/adl.test.js index 546bbf1a..5034f945 100644 --- a/test/adl.test.js +++ b/test/adl.test.js @@ -179,6 +179,7 @@ describe('Load models from json', function () { var m1 = new models.anonymous({title: 'Test'}); m1.should.have.property('title', 'Test'); + m1.should.have.property('author', 'Raymond'); models = loadSchemasSync(path.join(__dirname, 'test2-schemas.json')); models.should.have.property('address');