normal-it

1.0.1 • Public • Published

Normal-it

CircleCI codecov Dependencies

Quick Start

{
  "id": 1,
  "name": "Homer",
  "level": {
    "id": 2,
    "label": "level 1"
  }
}
import { normalize, Entity } from 'normal-it';


const Account = new Entity('accounts');
const Level = new Entity('levels');

Account.define({
  level: {
    entity: Level,
    type: 'belongsTo',
    foreignKey: 'levelId',
  },
});

const normalizedData = normalize(originalData, Account);

will produce

{
  "result": 1,
  "entities": {
    "accounts": {
      "1": {
        "id": 1,
        "name": "Homer",
        "levelId": 2
      }
    },
    "levels": {
      "2": {
        "id": 2,
        "label": "level 1"
      }
    }
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i normal-it

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • jdrouet