I am trying to create a really simple IndexedDB with some JavaScript, but it no longer works in the handler. Obviously, the browser (Chrome 57) cannot parse the keyPath (in Concepts ) of my repository.
I follow more or less the following simple examples: MDN or Opera-Dev .
Suppose I want to store objects like this in a DB:
{ "1": 23, // the unique id "2": 'Name', "3": 'Description', "4": null, "5": null }
Here is the code:
var sStoreNodes = 'nodes'; var sIdFieldNode = '1';
The error message reads as follows:
DOMException failed: Failed to execute 'createObjectStore' in 'IDBDatabase': keyPath parameter is not a valid path. in IDBOpenDBRequest.CCapIndexedDB.request.onupgradeneeded
I can also try to exclude the key path, but I wonder why this happens, and I want to, can I do this if I really need to use the (complex) key path.
Regarding the specification:
I'm not sure if this can be applied here:
A value is considered a valid key if it is one of the following ECMAScript types [ECMA-262]: a primitive Number value, a primitive String value, a Date object, or an Array object.
and what this actually means:
If the key path is DOMString, the value [to get the key path] will be DOMString equal to the key of the key. If the key path is a sequence, the value will be a new array filled with extra rows equal to each DOMString in the sequence.
Change This works if you are not using a string number, but instead a string that is a valid identifier (starting with the character [a-zA-Z]). So, 'keyPath' : 'b' is fine. I think this is because this value is used to create paths like abc .