2

Both PouchDB and Mango seem to be missing an option to include previous versions of a document in an index query.

Such an options might look something like: include_revs: true

So, for example, to retrieve a list of all the versions of a user's profile documents in a bucket prior to a specific timestamp, it might look something like this:

db.createIndex({
    index: {
         fields: [ 'user_id', 'type', 'timestamp' ],
         ddoc: 'all_versions',
         include_revs: true
    }
}).then(function(){
    db.find({
        selector: {
            user_id: specific_user,
            type: 'profile',
            timestamp: { $lte: specific_timestamp }
        },
        use_index: 'all_versions'
    }).then(function(results){
        // do something with revisions
    })
})

This feature seems like it would be very useful for handling merging conflicts as well as any situations where knowledge of the previous state matters. Is there a reason for why it is missing?

R J
  • 4,473
  • 2
  • 22
  • 29

1 Answers1

1

Change include_revs: true to either revs:true, 'revs_info:trueoropen_rev: 'all` to get an array of revs. chechout these answers Is there a way to get all revisions of a document in PouchDB when using the change feed?

Femi Oni
  • 796
  • 2
  • 9
  • 25