javascript-jsonapi-model-library

0.3.0 • Public • Published

javascript-jsonapi-model-library

NPM version Build Status Dependency Status

Provide base model to deal with jsonapi models

Installation

$ npm install --save javascript-jsonapi-model-library

Usage

import Model from 'javascript-jsonapi-model-library';
const schema = 'a json-schema';
 
class Profile extends Model {
    constructor(values) {
        super(values, schema);
 
        this.setJsonConfig({
            attributes: ['name', 'email']
        });
    }
}
 
let profile = new Profile({name: 'Simon', email: 'email@example.com', state: 'approved'});
 
assert(profile.get('name') === 'Simon');
 
try {
    profile.validate();
 
    reply(profile.toJson());
} catch (e) {
    // deal with error
}

License

© Simon Paitrault

Dependencies (4)

Dev Dependencies (16)

Package Sidebar

Install

npm i javascript-jsonapi-model-library

Weekly Downloads

1

Version

0.3.0

License

none

Last publish

Collaborators

  • fgribreau
  • freyskeyd
  • jsoulet
  • kyos
  • pagury