File tree Expand file tree Collapse file tree 3 files changed +6
-10
lines changed
Expand file tree Collapse file tree 3 files changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -3,12 +3,7 @@ const models = {};
33function model ( data ) {
44 // ToDo: Validate model
55 // ToDo: Check if model already exists to merge instead of set
6- // for(let prop in data) {
7- // if(data[prop].model) {
8- // data[prop] = models[data[prop].model];
9- // }
10- // }
11-
6+
127 models [ this . modelName ] = data ;
138
149 return this ;
Original file line number Diff line number Diff line change 11var util = require ( '../util' ) ;
22var models = require ( '../model' ) . models ;
3- // var validate = require('../validate');
43
54/**
6- * Type validator
5+ * Model validator
76 *
87 * {
9- * type : String // Check if data has a JS type (uses typeof)
8+ * model : String // Check if data has a model type
109 * }
1110 */
1211function isValid ( data , model ) {
@@ -17,11 +16,13 @@ function isValid(data, model) {
1716 var validate = module . parent . parent . exports ;
1817 var valid = validate ( data , { model : models [ model . model ] } ) ;
1918
19+ // Return if data is of model's type.
2020 // var eq = util.equal(data, valid);
2121 // return eq;
2222
2323 // Turn data into a valid model...
2424 reference ( data , valid ) ;
25+ // And return true (data is parsed, so data is modelated)
2526 return true ;
2627}
2728
Original file line number Diff line number Diff line change 11{
22 "name" : " modelate" ,
3- "version" : " 0.1 .0" ,
3+ "version" : " 0.2 .0" ,
44 "description" : " A simple data modeling tool for NodeJS" ,
55 "main" : " index.js" ,
66 "scripts" : {
You can’t perform that action at this time.
0 commit comments