gpt4 book ai didi

dart - 如何使用 Dart 在 IndexedDB 中使用复合键创建对象存储

转载 作者:行者123 更新时间:2023-12-04 19:33:32 26 4
gpt4 key购买 nike

JavaScript 可以使用

var objectStore = theDb.createObjectStore("store1", { keyPath: ["key1","key2"] });

使用复合键创建 ObjectStore。

但是如何在 dart 中做到这一点?

Dart 文档说:ObjectStore createObjectStore(String name, {String keyPath, bool autoIncrement})

keyPath是String,dart支持复合键吗?

最佳答案

你可以试试这个(像在 JavaScript 中一样工作 https://gist.github.com/nolanlawson/8330172 )

idb.ObjectStore objectStore = db.createObjectStore('persons', keyPath: 'name');

...

var persons = [
{'name': ['complex', 'key']},
{'name': ['very complex', 'key', 1]},
{'name': ['very complex', 'key', 2]},
{'name': ['very complex', 'key', 3]},
{'name': ['very complex', 'key', 'foo']}
];

...

objectStore.add(person).then((value) { ...

关于dart - 如何使用 Dart 在 IndexedDB 中使用复合键创建对象存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21400548/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com