如何使用Dart在IndexedDB中使用复合键创建对象库

时间:2014-01-28 08:37:48

标签: dart indexeddb dart-html

JavaScript可以使用

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

使用复合键创建ObjectStore

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

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

keyPath是一个String,是否支持复合键?

1 个答案:

答案 0 :(得分: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) { ...