在IDBObjectSore中使用keyPath这样创建indexedDB索引的方式是这样的:'location:location._id'

问题描述 投票:0回答:1

我在indexedDB存储中有一些数据,看起来像这样:

{
    "assetNo" : "00045455",
    "location:location" : {
        "title" : "19100003BRMA2879",
        "_id" : "5e2727cbc38a923f5826efb7"
    }
}

我想在该位置的_id上创建索引,但似乎indexedDB不喜欢location:location之间的冒号。我收到一个错误:DOMException:无法在'IDBObjectStore'上执行'createIndex':keyPath参数包含无效的密钥路径

冒号是一种约定,在成千上万的代码行中使用,因此仅对其进行更改将是一个问题。有什么办法解决吗?例如一种逃避结肠的方法?

indexeddb
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.