3

JavaScript can use

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

to create ObjectStore with compound key.

But how to do this in dart?

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

keyPath is a String, does dart support compound key?

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
ila
  • 31
  • 1

1 Answers1

0

You can try this (Works like in 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) { ...
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567