Standard Resource
  • Introduction
  • Read Me
  • Introduction
    • Motivation
    • Core Concepts
  • Store
    • Creating a Store
  • Resources
    • Resource Data
    • Creating
    • Retrieving
    • Updating
    • Deleting
    • Using Computed Attributes
    • Schemas
  • Groups
    • Creating
    • Retrieving
    • Updating
    • Deleting
    • Sorted Groups
  • API Reference
    • createResourceStore
    • Store
  • Glossary
  • Changelog
Powered by GitBook
On this page
  • Installation
  • Quick Start

Read Me

PreviousIntroductionNextIntroduction

Last updated 7 years ago

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 install standard-resource

or :

yarn add standard-resource

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.

npm
yarn
Travis build status
npm version
Test Coverage
gzip size