angular2-indexeddb icon indicating copy to clipboard operation
angular2-indexeddb copied to clipboard

GetByIndex returning Undefined

Open Maverik005 opened this issue 5 years ago • 0 comments

Here is my openDatabase

openDatabase(tableName: string,tableColumns: string[], indexedDBObj: AngularIndexedDB){ //Create DB Version 1 indexedDBObj.openDatabase(indexedDBObj.dbWrapper.dbVersion, (evt) => { let objectStore = evt.currentTarget.result.createObjectStore(tableName, { keyPath: "Id", autoIncrement: true }); tableColumns.forEach(col => { objectStore.createIndex(col, col, { unique: false }); }); }) }

Keypath:"Id" and I am creating index on every property of the object

Then I am trying to getByIndex like this:

indexedDBSelectByIndex(tableName:string, indexName:string, key:string,indexedDBObj: AngularIndexedDB ){ return indexedDBObj.getByIndex(tableName, indexName, key); } I am passing indexName as "UsedInRuleItemId",key as the value of the index, and storeName is tableName. It still retuning me undefined value. Ideally it should return the object that contains the value of the index I am passing to it.

Maverik005 avatar May 06 '20 07:05 Maverik005