https://github.com/iadvize/javascript-jsonapi-model-library
Provide base model to deal with jsonapi models
https://github.com/iadvize/javascript-jsonapi-model-library
jsonapi jsonapi-models models
Last synced: 9 months ago
JSON representation
Provide base model to deal with jsonapi models
- Host: GitHub
- URL: https://github.com/iadvize/javascript-jsonapi-model-library
- Owner: iadvize
- License: mit
- Created: 2016-01-13T10:22:31.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-03-01T13:18:43.000Z (over 8 years ago)
- Last Synced: 2025-07-11T11:52:20.560Z (11 months ago)
- Topics: jsonapi, jsonapi-models, models
- Language: JavaScript
- Homepage:
- Size: 54.7 KB
- Stars: 1
- Watchers: 45
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
javascript-jsonapi-model-library [![Build Status][circle-image]][circle-url] [![NPM version][npm-image]][npm-url] [![Dependency Status][daviddm-image]][daviddm-url]
================================
> Provide base model to deal with jsonapi models
## Examples
## Install
```sh
$ npm install --save javascript-jsonapi-model-library
```
## Documentation
### Usage
```js
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](CONTRIBUTING.md)
[npm-image]: https://badge.fury.io/js/javascript-jsonapi-model-library.svg
[npm-url]: https://npmjs.org/package/javascript-jsonapi-model-library
[circle-image]: https://circleci.com/gh/iadvize/javascript-jsonapi-model-library.svg?style=svg
[circle-url]: https://circleci.com/gh/iadvize/javascript-jsonapi-model-library
[daviddm-image]: https://david-dm.org/iAdvize/javascript-jsonapi-model-library.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/iAdvize/javascript-jsonapi-model-library