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

How to iterate the data #18

Open
kennylbj opened this issue Apr 16, 2022 · 5 comments
Open

How to iterate the data #18

kennylbj opened this issue Apr 16, 2022 · 5 comments

Comments

@kennylbj
Copy link

kennylbj commented Apr 16, 2022

I tried by following code but return error:

 for (const value of (this.keyvStore as any).iterator()) {
      console.log(value);
  }

ERROR : this.keyvStore.iterator is not a function or its return value is not iterable

Is that because the iterator function needs to be defined in keyv-file?

@SuiKaSan
Copy link

Hello, did you solve the problem?
I'm having the same situation.

@kennylbj
Copy link
Author

@SuiKaSan According to this document , the iterator function is needed to be defined in order to iterate over the dataset. It seems that the keyv-file did miss this part.

@TyrionFront
Copy link

+1

@broekema41
Copy link
Contributor

Created a pull request for this feature. Hoping for support to get iterators for keyv-file released. 😃
It's just so nice for devs to develop locally against some files in stead of having to start a docker-ized memory eating db.

@broekema41
Copy link
Contributor

Tested the iterator here in a actual project and had to do a bugfix. #22
When merged we can close this ticket as solved.

for await (const [key, value] of this.store.iterator()) {
  console.log(key, value);
};
const myIterator = this.store.iterator();
console.log(await myIterator.next());
console.log(await myIterator.next());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants