1.3.0 • Published 13 years ago
jungles-types
Licence
—
Version
1.3.0
Deps
4
Vulns
2
Weekly
0
Types
This module puts the validation layer infront of data.create, data.update and data.copy. So you don't always have to manually call validate when updating or creating data.
Create
var dal = require('jungles-data-memory')([]);
var settings = [ /* array with your types and schemas */ ];
var t = types(settings, dal).create({ name: 'snowboard', type: 'product' });
t.success(function (response) {
// response is the created object
});
t.error(function (errors) {
// errors are validation errors
});
Update
var dal = require('jungles-data-memory')([]);
var settings = [ /* array with your types and schemas */ ];
var t = types(settings, dal).update({ path '/snowboard', name: 'skateboard' });
t.success(function (response) {
// response is the updated object(s)
});
t.error(function (errors) {
// errors are validation errors
});
Copy
var dal = require('jungles-data-memory')([]);
var settings = [ /* array with your types and schemas */ ];
var t = types(settings, dal).copy({ path: '/snowboard', parent: '/' });
t.success(function (response) {
// response is the created object(s)
});
t.error(function (errors) {
// errors are validation errors
});