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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.3.0
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.3.0
    2
  • 0.2.0
    1
  • 0.1.1
    1
  • 0.1.0
    1

Package Sidebar

Install

npm i javascript-jsonapi-model-library

Weekly Downloads

5

Version

0.3.0

License

none

Last publish

Collaborators

  • fgribreau
  • freyskeyd
  • jsoulet
  • kyos
  • pagury