Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dexie-relationships

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dexie-relationships

Dexie relationship plugin

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
386
decreased by-36.41%
Maintainers
1
Weekly downloads
 
Created
Source

Dexie.js relationship plugin

Dexie.js is a wrapper library for indexedDB - the standard database in the browser.

Dexie relationship plugin provides an API to ease the loading of relational data from foreign tables

Installation

npm:

npm install dexie-relationships --save

bower:

bower install dexie-relationships --save

API Example

Schema

Note the use of -> which sets the foreign keys.

db.version(1).stores({
  projects: '++id',
  project_settings: '++id, project_id -> projects.id',
  project_members: '++id, project_id -> projects.id'
})
Seed the data
db.projects.add({name: 'Project #1'})
db.projects.add({name: 'Project #2'})

db.project_settings.add({name: 'Setting #1', project_id: 1})
db.project_settings.add({name: 'Setting #2', project_id: 2})
db.project_settings.add({name: 'Setting #3', project_id: 1})

db.project_members.add({name: 'Member #1', project_id: 1})
db.project_members.add({name: 'Member #2', project_id: 2})
db.project_members.add({name: 'Member #3', project_id: 1})
Usage
db.projects.with({
  'settings': 'project_settings',
  'members': 'project_members'
}).then(rows => console.log(rows))
Result
[  
  {  
    "name":"Project #1",
    "id":1,
    "settings":[  
      {  
        "name":"Setting #1",
        "project_id":1,
        "id":1
      },
      {  
        "name":"Setting #3",
        "project_id":1,
        "id":3
      }
    ],
    "members":[  
      {  
        "name":"Member #1",
        "project_id":1,
        "id":1
      },
      {  
        "name":"Member #3",
        "project_id":1,
        "id":3
      }
    ]
  },
  {  
    "name":"Project #2",
    "id":2,
    "settings":[  
      {  
        "name":"Setting #2",
        "project_id":2,
        "id":2
      }
    ],
    "members":[  
      {  
        "name":"Member #2",
        "project_id":2,
        "id":2
      }
    ]
  }
]

Keywords

FAQs

Package last updated on 26 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc