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

Return ID & Rev after Document PUT #123

Closed
N-Vlahovic opened this issue Aug 9, 2021 · 1 comment
Closed

Return ID & Rev after Document PUT #123

N-Vlahovic opened this issue Aug 9, 2021 · 1 comment

Comments

@N-Vlahovic
Copy link

Hi,

I am a long time couchdb-python user and am currently merging to couchdb2.

I was wondering if it is possible to return the doc id & rev when put-ing a single document (it is my understanding Database.put returns None).

The workaround would be doing something of the form

# ...
success, identifier, revision = db.update([doc])

While working, this workaround seems less satisfying than something like ... = db.put(doc).

Is there something I am missing or am being overly pedantic here? If not, do you think this feature would be worth considering?

Best regards,

@pekrau
Copy link
Owner

pekrau commented Nov 3, 2021

Both the _id and _rev are updated in the doc when doing db.put(doc). So I do not think it is necessary to return those values also.

You could create a subclass of Database and redefine put to do that, something like this:

class Database2(Database):
    def put(self, doc):
        super().put(doc)
        return doc["_id"], doc["_rev"]

@pekrau pekrau closed this as completed Nov 3, 2021
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

2 participants