THIS REPOSITORY IS ARCHIVED
simpl-schema-factory
Factory for SimpleSchema instances and publicFields. Standardizes your schema creation and keeps your code clean and encapsulated. You can also set a default schema, which gets attached to all your created schemas.
Installation
meteor add jkuester:simpl-schema-factory meteor npm install --save simpl-schema
Note: Throws an error, if you do not have the simpl-schema npm installed. No hard dependency on the deprecated aldeed:simple-schema package.
Basic Example
1 2const defaultSchemaObj = { 3 title: String, 4 description: { 5 type:String, 6 optional:true 7 }, 8 createdAt: Number, 9 createdBy:String, 10}; 11 12// set a default schema for all 13// newly created schemas 14SimpleSchemaFactory.defaultSchema(defaultSchemaObj); 15 16// creates a new instance of 17// the default schema 18const defaultSchemaInstance = SimpleSchemaFactory.defaultSchema(); 19 20 21const newSchemaObj = { 22 count: Number, 23 owner: String, 24}; 25 26// creates a combined schema 27// of newSchmaObj and defaultSchemaObj 28const newSchemaInstance = SimpleSchemaFactory.defaultSchemaWith(newSchemaObj); 29