You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Stefan Klein <st...@gmail.com> on 2021/05/26 08:17:10 UTC
Changes to 'this' in update function are visible in
validate_doc_update. Bug or Feature?
Hi all,
i'm trying to prevent unintended changes to some documents.
While toying around with update & validate_doc_update functions, I found
that, if i add a property to the `this` context of an update function, the
`this` context of the validate_doc_update running after the update contains
that property.
If I understand the couchdb & query server architecture correct I can not
rely on this behavior. Or can I?
Thanks & regards,
Stefan Klein
Re: Changes to 'this' in update function are visible in
validate_doc_update. Bug or Feature?
Posted by Stefan Klein <st...@gmail.com>.
Thank you Jan & ermouth for the fast replies.
Thought it's a feature I shouldn't rely to solve the issue.
I found a more obvious solution to prevent unintended edits: vdu checks
whether the current _rev is repeated in the doc as a validation token.
At least it prevents mindless editing via the admin interface, that's good
enough for my case.
regards,
Stefan Klein
Am Mi., 26. Mai 2021 um 11:02 Uhr schrieb ermouth <er...@gmail.com>:
> > Or can I?
>
> You better not unless you clearly understand how it works and what it
> depends on. However if you do, this bizzare feature can be invaluable for
> ie a sort of volatile cache, or (with a certain config) for altering params
> of a running filtered replication.
>
> Anyway, those tricks are very far from being conventional: they are nice to
> play with, but are no good for production.
>
> ermouth
>
>
> ср, 26 мая 2021 г. в 11:17, Stefan Klein <st...@gmail.com>:
>
> > Hi all,
> >
> > i'm trying to prevent unintended changes to some documents.
> >
> > While toying around with update & validate_doc_update functions, I found
> > that, if i add a property to the `this` context of an update function,
> the
> > `this` context of the validate_doc_update running after the update
> contains
> > that property.
> >
> > If I understand the couchdb & query server architecture correct I can not
> > rely on this behavior. Or can I?
> >
> > Thanks & regards,
> > Stefan Klein
> >
>
Re: Changes to 'this' in update function are visible in
validate_doc_update. Bug or Feature?
Posted by ermouth <er...@gmail.com>.
> Or can I?
You better not unless you clearly understand how it works and what it
depends on. However if you do, this bizzare feature can be invaluable for
ie a sort of volatile cache, or (with a certain config) for altering params
of a running filtered replication.
Anyway, those tricks are very far from being conventional: they are nice to
play with, but are no good for production.
ermouth
ср, 26 мая 2021 г. в 11:17, Stefan Klein <st...@gmail.com>:
> Hi all,
>
> i'm trying to prevent unintended changes to some documents.
>
> While toying around with update & validate_doc_update functions, I found
> that, if i add a property to the `this` context of an update function, the
> `this` context of the validate_doc_update running after the update contains
> that property.
>
> If I understand the couchdb & query server architecture correct I can not
> rely on this behavior. Or can I?
>
> Thanks & regards,
> Stefan Klein
>
Re: Changes to 'this' in update function are visible in
validate_doc_update. Bug or Feature?
Posted by Jan Lehnardt <ja...@apache.org>.
Hi Stefan,
you absolutely should and can not rely on this behaviour, it might even
not be available in setups with other (more modern) JS interpreters.
Best
Jan
—
Professional Support for Apache CouchDB:
https://neighbourhood.ie/couchdb-support/
24/7 Observation for your CouchDB Instances:
https://opservatory.app
> On 26. May 2021, at 10:17, Stefan Klein <st...@gmail.com> wrote:
>
> Hi all,
>
> i'm trying to prevent unintended changes to some documents.
>
> While toying around with update & validate_doc_update functions, I found
> that, if i add a property to the `this` context of an update function, the
> `this` context of the validate_doc_update running after the update contains
> that property.
>
> If I understand the couchdb & query server architecture correct I can not
> rely on this behavior. Or can I?
>
> Thanks & regards,
> Stefan Klein