首页 > 解决方案 > How to define and use database relationships in dexie js?

问题描述

Is it possible to create a relationship in indexDB using Dexie js

If possible how to define and use them ?

i have tried looking through the Dexie js documentation they haven't mentioned database relationship anywhere

Dexie documention

标签: indexeddbdexie

解决方案


Yes, there is package dexie-relationships. I've tried it but finally remove. Cuz:

  1. indexedDb does not have real relationships like I used to in MySQL. This library is just sugar over dexie.
  2. I faced problem with drop table, cuz reltionships library does not accepts null in table definition (tries to null.split() it).
  3. Instead of that library I use simple repositories (classes or functions) to fetch all required data with short syntax. And so you don't need relationships library cuz all relations are hidden in repositories and you don't need to use relations directly.
  4. Dexie v3.0 is now in beta.1 stage and I don't know whether compatible with dexie-relationships or would ever.

PS: too late, but I think it should be published. It would save me a lot of time if I read this few month before.


推荐阅读