ngx-indexed-db icon indicating copy to clipboard operation
ngx-indexed-db copied to clipboard

Readme for cursor api is not valid

Open Celtian opened this issue 2 years ago • 1 comments

This block of code is not compatible with current version

db.openCursor('people', (evt) => {
    var cursor = (<any>evt.target).result;
    if(cursor) {
        console.log(cursor.value);
        cursor.continue();
    } else {
        console.log('Entries all displayed.');
    }
}, IDBKeyRange.bound("A", "F"));

as I can see in source code, typings is copletely incompatible

/**
* Returns the open cursor event
* @param storeName The name of the store to have the entries deleted
* @param keyRange The key range which the cursor should be open on
*/
openCursor(storeName: string, keyRange?: IDBKeyRange): Observable<Event>;

Can you please update it? Now I am unable to iterate over your api ...

Celtian avatar Jul 23 '22 14:07 Celtian

I have already found some solution, but it is probably too complicated and wrong ...

  this.dbService.openCursor('table-name').subscribe((evt: any) => {
      const cursor: IDBCursorWithValue = evt.target.result;
      if (cursor) {
        console.log(cursor.value);
        cursor.continue();
      } else {
        console.log('Entries all displayed.');
      }
      const target: IDBRequest = evt.target;
      target.onsuccess = (): void => {
        const cursor: IDBCursorWithValue = evt.target.result;
        if (cursor) {
          console.log(cursor.value);
          cursor.continue();
        } else {
          console.log('Entries all displayed.');
        }
      };
    });

Celtian avatar Jul 24 '22 07:07 Celtian