-
Notifications
You must be signed in to change notification settings - Fork 540
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
Add Table.write_back(), replacing documents by ids #184
Conversation
Compare to `update()`, `replace()` provide a more customizable workflow to modify documents. One can fistly search the documents and modify them by thier conditions, then input new douments with thier `doc_ids` to `replace()`.
Seems like In the last commit a2992e6 is the best workaround I can get for now. Back to the topic, please let me know what you think about this |
Here's the pip installs for tinydb from PyPI for last month:
Source: 2.6 has been EOL for over 4 years. Can it be dropped? |
Just moved this to issue #185 :) |
Looks good to me 🙂 If @eugene-eeo doesn't have any objections, I'll be glad to merge this! |
Yeah, looks great! My only nitpick would be the name of the method... |
sure ! @eugene-eeo, I changed to Just found out that may cause data[doc_id] = documents.pop() So added a check in commit d0d0c8f |
OK, I also modified the example usage in top comment with the function name |
Merging master branch with Python 2.6 support dropped.
Merged with latest |
Hi @msiemens and @eugene-eeo , can we merge this ? |
LGTM but it's up to @msiemens to merge. Thanks for contributing! |
Sorry for the silence, everyone. I'm having two exams this week and am a little short on time. All in all, this looks good to me too. But I'd bring up the question of naming again. From an API usability perspective, I'd really prefer @eugene-eeo What do you think? |
@msiemens yeah I see your point which is something I considered at first, but the way I saw this was that it is a "lower level" version of |
That's a good point however. The question to me is whether this operation is something we would encourage everyday users or not. If we do encourage everyday use, |
I think it could be regarded as a lower level operation now, we can always change the method name with a deprecation warning in the future. |
That's a good idea! The last remaining question is where to document this. In |
Both in the API docs and advanced usage, IMO, and in the API docs we'll put a warning saying that it can be dangerous to use the method if you don't know what you're doing. |
If in P.S. @msiemens sorry, no mean to rush 😄 , hope for the best ! |
Just a quick note: I haven't forgotten about this PR and 'll probably revisit it at the end of next week 🙂 |
I've finally merged this and added some documentation. I'll release a new version of TinyDB in the next week or two 🙂 |
Thank you @msiemens ! |
This is now released in v3.8.0 🙂 |
Compare to
update()
,replace()
write_back()
provide a more customizable workflowto modify documents.
One can fistly search the documents and modify them by thier conditions,
then input new douments with thier
doc_ids
toreplace()
write_back()
.Example Usage
Or
replacewrite_back with new documentsCould be a convenient feature :)