3

JavaScript 可以使用

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

使用复合键创建 ObjectStore 。

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

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

keyPath 是一个字符串,dart 是否支持复合键?

4

1 回答 1

0

你可以试试这个(像 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) { ...
于 2014-01-28T08:44:15.103 回答