standard-resource

0.3.0 • Public • Published

Standard Resource

Travis build status npm version Test Coverage gzip size

A normalized data store.

✓ Works in Node or in the browser
✓ Normalizes data
✓ Flexible: define schemas for extra robustness, or choose not to
✘ Sophisticated relationship support (coming soon)

Installation

Note: this library is not yet ready to be used.

Install using npm:

npm install standard-resource

or yarn:

yarn add standard-resource

Documentation

View the documentation at standard-resource.js.org ⇗.

Quick Start

Follow this guide to get a taste of what it's like to work with Standard Resource.

First, we create a store. A store is where all of our resource data will be located.

import createResourceStore from 'standard-resource';
 
const store = createResourceStore();

Next, we can add a resource to the store. Let's create add a book with an ID of "24":

store.update('resources.books.24', {
  attributes: {
    name: 'The Lord of the Rings',
  },
});

Now that we have created our book, we can retrieve it.

console.log(store.getResources('books', ['24']));
// [
//   {
//     id: '24',
//     attributes: { name: 'Lord of the Rings' },
//     meta: {},
//     computedAttributes: {}
//   }
// ]

This is just a small sample of what it's like working with Standard Resource.

Package Sidebar

Install

npm i standard-resource

Weekly Downloads

1

Version

0.3.0

License

MIT

Unpacked Size

169 kB

Total Files

44

Last publish

Collaborators

  • jmeas