You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Florian Lohoff <f...@zz.de> on 2016/02/18 15:29:49 UTC

changes feed / include delete doc?

Hi,

i am trying to build a changes listener and for all docs which got
modified or deleted i'd like to get the last version for comparison.

I am right now using a construct like this:

	/couchdb/fidb/_changes?feed=continuous&since=X&include_docs=true&heartbeat=3000

Get the deleted or changed entrys - Fetch this:

	couchdb/fidb/<delorchangeddocid>?revs=true&open_revs=all

And then fetch the deleted/changed documents revision.

Is there an easier way i simply didnt recognize?  include_last_rev=true ?

Flo
-- 
Florian Lohoff                                                 f@zz.de
      We need to self-defend - GnuPG/PGP enable your email today!

Re: changes feed / include delete doc?

Posted by Florian Westreicher <st...@meredrica.org>.
You could add a deleted flag instead of deleting them initially. Then 
process the doc and delete it afterwards.


On February 23, 2016 12:45:53 Sebastian Rothbucher 
<se...@googlemail.com> wrote:

> Hi Flo,
>
> maybe update handler functions are what you're looking for:
> http://docs.couchdb.org/en/1.6.1/couchapp/ddocs.html#update-functions
>
> Good luck & best
>     Sebastian
>
> On Sun, Feb 21, 2016 at 6:23 PM, Florian Lohoff <f...@zz.de> wrote:
>
>> On Sun, Feb 21, 2016 at 05:38:29PM +0100, Sebastian Rothbucher wrote:
>> > Hi Flo,
>> >
>> > Exactly, you can't rely on prev versions - you'die have to keep your
>> > own deleted and history 4 that...
>>
>> So either i can t
>>
>> - do a replication middleware e.g. _changes feed listener
>>   writing into a secondary database so in case an update/delete i can
>>   fetch the old version from the secondary database before actually
>>   applying the chage.
>> - write a middleware updating the database through the middleware only
>>   and generating "changes" documents or the like.
>>
>> I'd wish there were something like include_docs but
>> include_old_docs in the changes feed.
>>
>> Flo
>> --
>> Florian Lohoff                                                 f@zz.de
>>       We need to self-defend - GnuPG/PGP enable your email today!
>>
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.10 (GNU/Linux)
>>
>> iQIVAwUBVsnyjpDdQSDLCfIvAQpDIRAAiK1sklo9uN/ifX8T9J4IgBViA90BA8p9
>> G38CeBkhTPgFRs2dL+g+UwrvgIyTiP8/lvyV3ectYAx+QeTbw/s+128qeF2hCkm2
>> 9FUYSxdrePH1487NZ+tGx0fONycPVsRpHxA3o53ZrCjePkUickULeTmp5xKVlEnY
>> n73gq/QE83RWcfodUVldPxiu70UGiqLLeOPOi7b5Va4RhxlgycdQhoZXEiF3GxA3
>> j0KESBMvLZxVXAYXLG0psi6b3ZN/rKmKocnggPFDtrr83k5vhF/NV5VhO55NhEU8
>> DSsLmwUQdtbvOY2/xwgVXZCUpXiqvuzz636FbT5Vpm8z7hB2Z43GIq5BOJEyGX7W
>> joqp7G+10gBxDatqnw6vgEiTz1RSdve4Smr9esMR0s3ODlkqOj3ZaY3F3z4Lk7f/
>> 73nBnbIE6AffBGr3mf9Q404SrFzdbT2qsShb+kxTyWOtgKxKTgPYbbBEuDh//GzM
>> qLchjLc+1myxiRm5UchfraEk3KUnlAifrLbJOL+bW6CI+g5Xd3u5XMtJWJS53YrV
>> yYm/F9T7f+ZDQz71V1r91MnjirCS1ksJH+WqZ1EcjOJtSBQUF6Bd6MOYMn1wa9Bg
>> G6a2NC3sDd4I+6X3NBP9pAY55SF3YLO9RQ/zXOz4Yw7QTf3Ww+vz/QQNxKs9AfhG
>> p6+SzVpbgvo=
>> =Qz4d
>> -----END PGP SIGNATURE-----
>>
>>



Re: changes feed / include delete doc?

Posted by Sebastian Rothbucher <se...@googlemail.com>.
Hi Flo,

maybe update handler functions are what you're looking for:
http://docs.couchdb.org/en/1.6.1/couchapp/ddocs.html#update-functions

Good luck & best
    Sebastian

On Sun, Feb 21, 2016 at 6:23 PM, Florian Lohoff <f...@zz.de> wrote:

> On Sun, Feb 21, 2016 at 05:38:29PM +0100, Sebastian Rothbucher wrote:
> > Hi Flo,
> >
> > Exactly, you can't rely on prev versions - you'die have to keep your
> > own deleted and history 4 that...
>
> So either i can t
>
> - do a replication middleware e.g. _changes feed listener
>   writing into a secondary database so in case an update/delete i can
>   fetch the old version from the secondary database before actually
>   applying the chage.
> - write a middleware updating the database through the middleware only
>   and generating "changes" documents or the like.
>
> I'd wish there were something like include_docs but
> include_old_docs in the changes feed.
>
> Flo
> --
> Florian Lohoff                                                 f@zz.de
>       We need to self-defend - GnuPG/PGP enable your email today!
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iQIVAwUBVsnyjpDdQSDLCfIvAQpDIRAAiK1sklo9uN/ifX8T9J4IgBViA90BA8p9
> G38CeBkhTPgFRs2dL+g+UwrvgIyTiP8/lvyV3ectYAx+QeTbw/s+128qeF2hCkm2
> 9FUYSxdrePH1487NZ+tGx0fONycPVsRpHxA3o53ZrCjePkUickULeTmp5xKVlEnY
> n73gq/QE83RWcfodUVldPxiu70UGiqLLeOPOi7b5Va4RhxlgycdQhoZXEiF3GxA3
> j0KESBMvLZxVXAYXLG0psi6b3ZN/rKmKocnggPFDtrr83k5vhF/NV5VhO55NhEU8
> DSsLmwUQdtbvOY2/xwgVXZCUpXiqvuzz636FbT5Vpm8z7hB2Z43GIq5BOJEyGX7W
> joqp7G+10gBxDatqnw6vgEiTz1RSdve4Smr9esMR0s3ODlkqOj3ZaY3F3z4Lk7f/
> 73nBnbIE6AffBGr3mf9Q404SrFzdbT2qsShb+kxTyWOtgKxKTgPYbbBEuDh//GzM
> qLchjLc+1myxiRm5UchfraEk3KUnlAifrLbJOL+bW6CI+g5Xd3u5XMtJWJS53YrV
> yYm/F9T7f+ZDQz71V1r91MnjirCS1ksJH+WqZ1EcjOJtSBQUF6Bd6MOYMn1wa9Bg
> G6a2NC3sDd4I+6X3NBP9pAY55SF3YLO9RQ/zXOz4Yw7QTf3Ww+vz/QQNxKs9AfhG
> p6+SzVpbgvo=
> =Qz4d
> -----END PGP SIGNATURE-----
>
>

Re: changes feed / include delete doc?

Posted by Florian Lohoff <f...@zz.de>.
On Sun, Feb 21, 2016 at 05:38:29PM +0100, Sebastian Rothbucher wrote:
> Hi Flo,
> 
> Exactly, you can't rely on prev versions - you'die have to keep your
> own deleted and history 4 that...

So either i can t

- do a replication middleware e.g. _changes feed listener
  writing into a secondary database so in case an update/delete i can
  fetch the old version from the secondary database before actually
  applying the chage.
- write a middleware updating the database through the middleware only
  and generating "changes" documents or the like.

I'd wish there were something like include_docs but
include_old_docs in the changes feed. 

Flo
-- 
Florian Lohoff                                                 f@zz.de
      We need to self-defend - GnuPG/PGP enable your email today!

Re: changes feed / include delete doc?

Posted by Sebastian Rothbucher <se...@googlemail.com>.
Hi Flo,

Exactly, you can't rely on prev versions - you'die have to keep your own deleted and history 4 that...

Good luck
   Sebastian 

Von meinem iPhone gesendet

> Am 21.02.2016 um 17:08 schrieb Florian Lohoff <f...@zz.de>:
> 
>> On Sun, Feb 21, 2016 at 03:27:38PM +0100, Sebastian Rothbucher wrote:
>> Hi Flo,
>> 
>> if I'm not completely mistaken, the changes feed does contain the last
>> revision of a modified document or a deletion stub. See the following
>> example:
>> $ curl -X GET '
>> http://localhost:5984/test/_changes?feed=continuous&heartbeat=3000'
>> # (some changes)
>> # fire foff
>> $ curl -X PUT 'http://localhost:5984/test/bla' -d '{}'
>> {"ok":true,"id":"bla","rev":"1-967a00dff5e02add41819138abb3284d"}
>> # produces changes feed
>> {"seq":4,"id":"bla","changes":[{"rev":"1-967a00dff5e02add41819138abb3284d"}]}
>> # fire off
>> $ curl -X DELETE '
>> http://localhost:5984/test/bla?rev=1-967a00dff5e02add41819138abb3284d'
>> {"ok":true,"id":"bla","rev":"2-eec205a9d413992850a6e32678485900"}
>> # produces changes feed
>> {"seq":5,"id":"bla","changes":[{"rev":"2-eec205a9d413992850a6e32678485900"}],"deleted":true}
>> 
>> 2-eec205a9d413992850a6e32678485900 is in fact the deletion stub's revision
>> ID
>> 
>> hope if helps - otherwise pls. let us know
> 
> Yes - but 2-eec205a9d413992850a6e32678485900 is only the deletion stub
> not the last valid document. I'd like to have the last document before
> the deletion stub.
> 
> e.g. the pre-delete or pre-change/update document. I'd like to process
> differences in objects so i need to have a look at document changes for
> which i need the new and the old document.
> 
> Reading from the semantics of revisions i should not even rely on them 
> beeing existant (I now they disappear on compaction).
> 
> Flo
> -- 
> Florian Lohoff                                                 f@zz.de
>      We need to self-defend - GnuPG/PGP enable your email today!

Re: changes feed / include delete doc?

Posted by Florian Lohoff <f...@zz.de>.
On Sun, Feb 21, 2016 at 03:27:38PM +0100, Sebastian Rothbucher wrote:
> Hi Flo,
> 
> if I'm not completely mistaken, the changes feed does contain the last
> revision of a modified document or a deletion stub. See the following
> example:
> $ curl -X GET '
> http://localhost:5984/test/_changes?feed=continuous&heartbeat=3000'
> # (some changes)
> # fire foff
> $ curl -X PUT 'http://localhost:5984/test/bla' -d '{}'
> {"ok":true,"id":"bla","rev":"1-967a00dff5e02add41819138abb3284d"}
> # produces changes feed
> {"seq":4,"id":"bla","changes":[{"rev":"1-967a00dff5e02add41819138abb3284d"}]}
> # fire off
> $ curl -X DELETE '
> http://localhost:5984/test/bla?rev=1-967a00dff5e02add41819138abb3284d'
> {"ok":true,"id":"bla","rev":"2-eec205a9d413992850a6e32678485900"}
> # produces changes feed
> {"seq":5,"id":"bla","changes":[{"rev":"2-eec205a9d413992850a6e32678485900"}],"deleted":true}
> 
> 2-eec205a9d413992850a6e32678485900 is in fact the deletion stub's revision
> ID
> 
> hope if helps - otherwise pls. let us know

Yes - but 2-eec205a9d413992850a6e32678485900 is only the deletion stub
not the last valid document. I'd like to have the last document before
the deletion stub.

e.g. the pre-delete or pre-change/update document. I'd like to process
differences in objects so i need to have a look at document changes for
which i need the new and the old document.

Reading from the semantics of revisions i should not even rely on them 
beeing existant (I now they disappear on compaction).

Flo
-- 
Florian Lohoff                                                 f@zz.de
      We need to self-defend - GnuPG/PGP enable your email today!

Re: changes feed / include delete doc?

Posted by Sebastian Rothbucher <se...@googlemail.com>.
Hi Flo,

if I'm not completely mistaken, the changes feed does contain the last
revision of a modified document or a deletion stub. See the following
example:
$ curl -X GET '
http://localhost:5984/test/_changes?feed=continuous&heartbeat=3000'
# (some changes)
# fire foff
$ curl -X PUT 'http://localhost:5984/test/bla' -d '{}'
{"ok":true,"id":"bla","rev":"1-967a00dff5e02add41819138abb3284d"}
# produces changes feed
{"seq":4,"id":"bla","changes":[{"rev":"1-967a00dff5e02add41819138abb3284d"}]}
# fire off
$ curl -X DELETE '
http://localhost:5984/test/bla?rev=1-967a00dff5e02add41819138abb3284d'
{"ok":true,"id":"bla","rev":"2-eec205a9d413992850a6e32678485900"}
# produces changes feed
{"seq":5,"id":"bla","changes":[{"rev":"2-eec205a9d413992850a6e32678485900"}],"deleted":true}

2-eec205a9d413992850a6e32678485900 is in fact the deletion stub's revision
ID

hope if helps - otherwise pls. let us know

Best
      Sebastian

On Thu, Feb 18, 2016 at 3:29 PM, Florian Lohoff <f...@zz.de> wrote:

>
> Hi,
>
> i am trying to build a changes listener and for all docs which got
> modified or deleted i'd like to get the last version for comparison.
>
> I am right now using a construct like this:
>
>
> /couchdb/fidb/_changes?feed=continuous&since=X&include_docs=true&heartbeat=3000
>
> Get the deleted or changed entrys - Fetch this:
>
>         couchdb/fidb/<delorchangeddocid>?revs=true&open_revs=all
>
> And then fetch the deleted/changed documents revision.
>
> Is there an easier way i simply didnt recognize?  include_last_rev=true ?
>
> Flo
> --
> Florian Lohoff                                                 f@zz.de
>       We need to self-defend - GnuPG/PGP enable your email today!
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iQIVAwUBVsXVXZDdQSDLCfIvAQoM4g//Zb3x2RYWzP2xmZS/Bn8DtnKzPYom2IhN
> lqi/99/WYhtTDsGQroPF06z7oLFG5+/QmgswOSrAYq+4wMGLzdVwFINCoYDhionQ
> EqcKbfuu1Rd0zGPXUaGdHNfNvpRd6lHjRIvrEmsBz/2+toMMO/59p01R2GDdecsc
> 5kFlhxrBjCR0j9b+f6gQqKVoY5iq6Rc7947ukx0Ja4D7Orlp/MP95wyKI+o9IS5w
> rozMDW8Dy46DQbwMwO+tz4RKPMVpug7DOvPH7p+RS1nm7TrnZV0Db5ZeM7mynIN/
> T7mqa+Anc+L2efEhZAVLv2dGDXikndS0SBKHsxYimFcv6U1eJ7mz5aMhOnsmnelu
> ed/MUsuofmo056JksW5pNjPukCTFzcSwEC8BL4L315BhW6BY9r4CT+BoT32LB3UI
> Q2TNiAhG+xl5LUI9ScCtdPflEidpWflk41Erbk0gdwaLw+BevMinsYGJAhJtN7ji
> 8An4gPPUCWLSjFAB7e8eFPHTIQhvySTkaqnSbsdfEdzc9oEEo87c4shLBZqHMzsE
> UmPF+O/1d7Ynx5jCjob3+T8PrR7iI9oCwGlrjbM6BL2VnAu46R6iKtGTs00Chg0p
> uekXO58gN+wrcUrc3QL66j7B1DK10PS0TELBW9hULfq6oyiDrK7WEZXIPZZW2tbY
> jXlnkGTYvDs=
> =AlS3
> -----END PGP SIGNATURE-----
>
>