Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the total number (size) of the LevelDB keys #96

Open
huan opened this issue Oct 10, 2021 · 0 comments
Open

Get the total number (size) of the LevelDB keys #96

huan opened this issue Oct 10, 2021 · 0 comments

Comments

@huan
Copy link
Owner

huan commented Oct 10, 2021

Current we are using a for loop to loop all keys to count:

public get size (): Promise<number> {
log.verbose('FlashStore', 'size()')
/* eslint no-async-promise-executor: 0 */
// TODO: is there a better way to count all items from the db?
return new Promise<number>(async (resolve, reject) => {
try {
let count = 0
for await (const _ of this) {
count++
}

Related links:

huan added a commit that referenced this issue Oct 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant