huan / flash-store

FlashStore is a high-performance Key-Value Persistent Local Database using ES6 Map's API (Async & Sync), Powered by LevelDB/RocksDB/SQLite and TypeScript.
https://paka.dev/npm/flash-store
Apache License 2.0
20 stars 4 forks source link

Little confused about FlashStore.size #50

Closed su-chang closed 4 years ago

su-chang commented 4 years ago

In FlashStore, set value to the same key more than one time will make the size wrong, but no Error.

If we set the same key more than one time

await flashStore.set('name', '1')
await flashStore.set('name', '2')
await flashStore.set('name', '3')
const size = await flashStore.size // size: 3

and then let's restart the script again, size: 4.

If execute this script only

const size = await flashStore.size // size: 1, right!

I'm confused with this case.

BTW, Im trying to find out the reason about Issue: https://github.com/botorange/wechaty-puppet-padpro/pull/191

huan commented 4 years ago

Thanks for the reporting.

Could you please help me to add an unit test, which can reproduce your case, and make the test fail?

Thank you very much.

huan commented 4 years ago

@su-chang Thanks for the unit test, and that's a great catch!

We are now tracking this issue at https://github.com/ClickSimply/snap-db/pull/12

huan commented 4 years ago

Fixed by #69