jakearchibald / idb

IndexedDB, but with promises
https://www.npmjs.com/package/idb
ISC License
6.29k stars 353 forks source link

createIndex with special character "@" in keyPath and nested objects #202

Closed marcuslindblom closed 3 years ago

marcuslindblom commented 3 years ago

Is it possible to create an index on this key store.createIndex('name', '@metadata.@foo.name');

jakearchibald commented 3 years ago

Have you tried?

marcuslindblom commented 3 years ago

Oh yes, sorry. I have tested and the above throws this exception Failed to execute 'createIndex' on 'IDBObjectStore': The keyPath argument contains an invalid key path.. I Guess my question was a bit vague. I thought maybe it is possible to use another syntax for this, or escape the @ sign in some way to make it work.

jakearchibald commented 3 years ago

It seems like keypath elements need to valid identifiers right now. Some discussion here https://github.com/w3c/IndexedDB/issues/209#issuecomment-533404075