【问题标题】:Specify different unique key in Dexie database schema?在 Dexie 数据库模式中指定不同的唯一键?
【发布时间】:2020-01-22 20:19:45
【问题描述】:

我的基本 dexie 数据库方案是这样的。

const db = new Dexie('MyDatabase');

// Declare tables, IDs and indexes
db.version(1).stores({
    myrecords: 'record_id'
});

我想使用我的record_id 作为唯一键。在 indexeddb 中,我可以像下面这样进行操作

 var myrecordsObjectStore = db.createObjectStore('myrecords' , {
                                keyPath: 'record_id'
                            });

【问题讨论】:

    标签: javascript indexeddb dexie dexiejs


    【解决方案1】:

    应该使用 & 前缀作为文档中所述的唯一性

    db.version(1).stores({
        myrecords: '&record_id'
    });
    

    Dexie Quick Reference

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-25
      • 2018-09-25
      • 2018-08-31
      • 1970-01-01
      • 2017-11-17
      • 2012-04-23
      • 2015-03-08
      • 2014-10-06
      相关资源
      最近更新 更多