immutable-struct
v0.1.0
Published
package for creating immutable models, specifically for upholding api contracts (think DTO)
Downloads
2
Readme
here is how you use it
var obj = {
string: {type: 'string' },
number: {type: 'number'},
boolean: {type: 'boolean'},
enum: {type: 'string', values: ['TEST1', 'TEST2', 'TEST3']},
array: {type: 'array:string', values: ['test1', 'test2']},
object: {type: 'object', instanceOf: ParentModel}
}
var Obj = model.create(obj);
var myObj = newObj();
myObj.setNumber(10);
myObj.getNumber(); // returns 10
// or
var myObj = newObj( {string: 'stringInit', number: 20, boolean: false} );
ideally you would have each model in it's own file with module.exports = model.create(obj)