thisdot / open-source

Repository for open source packages
MIT License
34 stars 11 forks source link

Add support for `addItem`, `keys` and `entries` methods to the library #77

Closed TapaiBalazs closed 2 years ago

TapaiBalazs commented 2 years ago

Is your feature request related to a problem? Please describe.

The cypres-indexeddb library is good for inserting items into the database using keys, but you can add values without using a key. See documentation:

/**
     * Adds or updates a record in store with the given value and key.
     *
     * If the store uses in-line keys and key is specified a "DataError" DOMException will be thrown.
     *
     * If put() is used, any existing record with the key will be replaced. If add() is used, and if a record with the key already exists the request will fail, with request's error set to a "ConstraintError" DOMException.
     *
     * If successful, request's result will be the record's key.
     */
    add(value: any, key?: IDBValidKey): IDBRequest<IDBValidKey>;

I'd also like to have support for getting an ObjectStore's keys and values, so I could make assertions

Describe the solution you'd like

I'd like to have the above mentioned new methods in the library

addItem:

  cy.getStore('@myStore')
    .addItem('testValue') // calls 'add' without a 'key' property passed.

keys:

  cy.getStore('@myStore')
    .keys()
    .should('have.length', 10)

entries:

  cy.getStore('@myStore')
    .entries()
    .then(entries => /* do stuff */)

Describe alternatives you've considered

-

Addtional context

-