Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

How can I get revisions? | How to get data back by using id and revision code? #493

Closed
yingshaoxo opened this issue Mar 30, 2021 · 2 comments
Assignees

Comments

@yingshaoxo
Copy link

How to get revisions

Here is the code:

db.create_document({
    #'_id': get_uuid(),
    '_id': "yingshaoxo",
    'sex': 'man',
    'age': 1 
})

doc = db["yingshaoxo"]

doc_url = doc.document_url
doc_rev = doc["_rev"]

response = db.r_session.get(doc_url + "?revs=true")
print(response.json())

For the above code, I could get the revisions:

{'_id': 'yingshaoxo',
 '_rev': '2-23264daadf4391d830db8b811aea35bb',
 'sex': 'girl',
 'age': 1,
 '_revisions': {'start': 2,
  'ids': ['23264daadf4391d830db8b811aea35bb',
   'cfb1374d66b1ffdcb7d0d9f0e33e01ce']}}

But when I use db["yingshaoxo"], I couldn't get _revisions, where is the problem, guys?

{'_id': 'yingshaoxo',
 '_rev': '2-23264daadf4391d830db8b811aea35bb',
 'sex': 'girl',
 'age': 1}

How to get data back by using _id and one element that comes from the _reversions?

This is essential if we want to recover some data from the history records.

@yingshaoxo yingshaoxo changed the title How can I get revisions and from id and revision get the data back? How can I get revisions? | How to get data back by using id and revision code? Mar 30, 2021
@rnewson
Copy link
Contributor

rnewson commented Mar 30, 2021

Hi,

Cloudant automatically deletes old revisions so you cannot rely on them being retrievable. If you need to preserve historical versions of your documents you will need a different tactic.

@yingshaoxo
Copy link
Author

Hi,

Cloudant automatically deletes old revisions so you cannot rely on them being retrievable. If you need to preserve historical versions of your documents you will need a different tactic.

Alright, thank you for the answer.

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

No branches or pull requests

3 participants