8

I am fetching data from indexeddb using where class using jsstore.I got response.But getting "Failed to execute 'only' on 'IDBKeyRange': The parameter is not a valid key. " console error.Why I am getting this error.can anyone pls help me.

//Get DBSchema(table & columns)
  private getDbSchema = function () {
    const tblArticle = {
      Name: this._indexedDBLiveDBTableName,
      Columns: [
       {
          Name: 'ParentName',
          NotNull: true,
          DataType: 'string'
        },
        {
          Name: 'ChildName',
          NotNull: true,
          DataType: 'string'
        }
        ,
        {
          Name: 'UpdatedDate',
          NotNull: true,
          DataType: 'string'
        }
      ]
    };

    const Database = {
      Name: this._indexedDBLiveDBName,
      Tables: [tblArticle]
    };
    return Database as any;
  };

 //Fetch articles From IndexedDB
GetArticleFromIndexedDb(section) {
    this._connection.openDb(this._indexedDBLiveDBName);
    return this._connection.select({
      From: this._indexedDBLiveDBTableName,
      Where: {
        ChildName: section
      }
    });
 }

value of section will be like "India","TamilNadu"

Kindly find the attached screenshot for error

here

I am using jsstore 1.3.0

I updated jsstore version to 1.4.1 which is giving "Maximum call stack size exceeded"

enter image description here

Thanks

Ujjwal Kumar Gupta
  • 2,308
  • 1
  • 21
  • 32
kamalav
  • 1,190
  • 4
  • 14
  • 31

2 Answers2

14

It is due to the invalid value supplied. IndexedDB support list of value - numbers, dates, strings, binary data, array : which are valid keys.

This error is generally thrown when you are passing - boolean,null or undefined value.

Check out w3c for more info - https://w3c.github.io/IndexedDB/#key-construct

Ujjwal Kumar Gupta
  • 2,308
  • 1
  • 21
  • 32
  • For others - yes, you can't query null/true/false, you have to first convert them to a string and query for that ... – jave.web Dec 17 '22 at 22:28
0

For anyone else who is having this same issue and is actually passing a valid key, it could actually be that you are running.

objectStore.put(key, value)

when you should run

objectStore.put(value, key)

It's in reverse by the specs.

Onza
  • 1,710
  • 4
  • 18
  • 31