Skip to content

iadvize/javascript-jsonapi-model-library

Repository files navigation

javascript-jsonapi-model-library Build Status NPM version Dependency Status

Provide base model to deal with jsonapi models

Examples

Install

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

Documentation

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
}

Contribute

Look at contribution guidelines here : CONTRIBUTING.md

About

Provide base model to deal with jsonapi models

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •