snowstorm
Simple Javascript ORM
❄️ Getting Started
Installation
npm install snowstorm
Example
Create a model and define the properties of the model
var snowstorm = ; // Define the model and its propertiesvar Task = snowstorm;
Add methods to the prototype layer
Taskprototype { return thiscompleted;};
Create an instance of a task
// Data from servervar responseData = title: 'Task out the trash' completed: false created_at: '2015-08-20T10:00:00.000Z';var task = responseData;
Access the properties/methods of the task or convert to JSON to send back to the server
console; // Task out the trashconsole; // Thu Aug 20 2015 04:00:00 GMT-0600 (MDT)console; // false // Send back to servervar requestData = task;
❄️ API
Create a model class
snowstorm;
Define a property to be used on the model
snowstormPropertiesstring// orsnowstormProperties
Properties | Arguments |
---|---|
snowstorm.Properties.string |
attr |
snowstorm.Properties.number |
attr |
snowstorm.Properties.boolean |
attr |
snowstorm.Properties.array |
attr |
snowstorm.Properties.object |
attr |
snowstorm.Properties.date |
attr , format |
snowstorm.Properties.model |
attr , modelClass |
Create a custom property
var Moment = ; // https://github.com/moment/moment/ { return attr: attr { if typeof d === 'undefined' return null; return ; } { if !d return null; return d; } }; // Usagevar Todo = snowstorm;
❄️ Running tests
npm install
npm test