jungles-types

1.3.0 • Public • Published

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
});

Readme

Keywords

none

Package Sidebar

Install

npm i jungles-types

Weekly Downloads

11

Version

1.3.0

License

none

Last publish

Collaborators

  • enome