Skip to content

Make table and db iterable#139

Merged
msiemens merged 2 commits intomsiemens:masterfrom
noirbizarre:iterable
Jun 5, 2017
Merged

Make table and db iterable#139
msiemens merged 2 commits intomsiemens:masterfrom
noirbizarre:iterable

Conversation

@noirbizarre
Copy link
Contributor

This PR makes Table iterable and TinyDB iterable over default table so it's possible to write:

# Iter over default table
db = TinyDB()
for obj in db:
   do_something(obj)
table = db.table('my_table')
for obj in table:
   do_something(obj)

@msiemens
Copy link
Owner

I think that's a nice addition. I'm still thinking about where this should be described in the docs: basic usage or advanced usage.

@eugene-eeo What do you think about this change?

@noirbizarre
Copy link
Contributor Author

I just added a simple documentation proposal

@eugene-eeo
Copy link
Contributor

@msiemens I'm fine with it since it opotimises for the 80% use case. But it needs to be documented somewhere. Perhaps in Basic Usage would be appropriate.

@msiemens msiemens merged commit 8da0adb into msiemens:master Jun 5, 2017
@msiemens
Copy link
Owner

msiemens commented Jun 5, 2017

since it opotimises for the 80% use case

Good point. I think it's quite intuitive for iter(db) to be an alias for db.all(). Thanks for the Pull Request @noirbizarre!

@msiemens
Copy link
Owner

msiemens commented Jun 5, 2017

Also, I've now released TinyDB v3.3.0 which includes this feature :)

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

Successfully merging this pull request may close these issues.

3 participants