Closed huisso97 closed 1 year ago
I think you're wanting to set an upper bound, not a lower bound.
(closing because it isn't an issue with this library. It's a general IDB question. But, I'm happy to continue helping)
thank you for replying !!
No problem. You can also pass your range object straight to .delete()
:
const db: IDBPDatabase<DBConfig> = await connectDB();
const range = IDBKeyRange.upperBound(new Date(Date.now() - 100000000));
await db.delete("test", range);
All of this assumes that the keys in your store are dates. You haven't shown your schema so I don't know that for sure.
I am connect IndexedDB like README code.
Then, I insert data into store named "test" with key which is date. I recognize that too many stored data cause browser loading to be longer, so I decided to delete some old data in store, iterating the store using cursor. And the next code is what I try. I intended to delete data of particular past time using IDBKeyRange, but all of data is deleted, not the bondary what i set.
So, I want to know how to delete some range of data. Thank you for your replying.