You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Panop Suvaphrom <PS...@vizrt.com> on 2011/10/13 00:58:36 UTC

Update the document without current version

Hi,

I know that it is not possible to update the document without current version.

But anyway, I would like to make sure about this.
Is there a way to update a document without knowing its current revision?
I would like to avoid first GETting current version…

Thanks a million,

Aun

Re: Update the document without current version

Posted by Mark Hahn <ma...@boutiquing.com>.
+1 for version override.  I have a number of places in my app where I have
to do a GET when I get an update conflict.  There are many cases where "the
last update should win" algorithm is appropriate.

I suspect couch designers were afraid developers would abuse this by being
lazy and not properly resolving conflicts.  If my paranoid suspicion is
true, then I would like to say that others shouldn't police me.

Re: Update the document without current version

Posted by Mehdi El Fadil <me...@mango-is.com>.
> Can you shed some more light on what application level features depend on
> the force_update/delete_conflicts
> API?
>

In case

   - the data from my document is coming from another location than couchdb
   ,
   - and I am using ids from that source system,
   - and my application user wants to overwrite document

then I avoiding to have to query for the current revision before updating
the doc would enhance performance and simplify development.

Re: Update the document without current version

Posted by Jens Alfke <je...@couchbase.com>.
On Oct 13, 2011, at 12:59 AM, Max Ogden wrote:

In your case you seem to be somehow replacing documents without first
knowing about them, which seems weird to me. Can you shed some more light on
what application level features depend on the force_update/delete_conflicts
API?

This does seem weird in many contexts, but I ran into a situation last month where it would have been useful: deleting a replication document from the _replicator database. The problem is that, while the replication is active, the server task is updating its document fairly frequently with new state info. Trying to stop the replication by deleting the document while this is going on can be frustrating because it’s a race condition — you get the latest revision, try to delete it, get a conflict, get the new revision, try to delete that, get another conflict… I finally had to write a loop that would keep doing the above over and over until it succeeded.

Based on this, I think it can be useful in some contexts to have an override that says “I want to delete (or overwrite) this document regardless of what its current state is”.

—Jens

Re: Update the document without current version

Posted by Alexander Uvarov <al...@gmail.com>.
On Oct 13, 2011, at 1:59 PM, Max Ogden wrote:

> Hi Alexander,
> 
> I think that the reason that force_update/delete_conflicts doesn't exist is
> because it's assumed that since HTTP is a stateless protocol that
> applications built using Couch will keep state on the client. For instance,
> if you update a document Couch will hand you back the new revision so you
> don't have to fetch it separately.
> 
> In your case you seem to be somehow replacing documents without first
> knowing about them, which seems weird to me. Can you shed some more light on
> what application level features depend on the force_update/delete_conflicts
> API?

Just an idea on top of Panop question.

For example: user know about several conflicts and wanna save his version
and purge all other conflicted revs. Some server side support would be useful in this case.
Well, omitting revisions in an update request is worst, indeed, thus my proposal becomes offtopic.
I'll rethink and probably post separate feature request later.

> 
> Max
> 
> On Thu, Oct 13, 2011 at 12:26 AM, Alexander Uvarov <
> alexander.uvarov@gmail.com> wrote:
> 
>> I would prefer a parameter like "force_update=true" and
>> "delete_conflicts=true" to purge all existing versions and conflicts and
>> just save new one. Would be useful for cases when user need to overwrite
>> existing versions or when conflicts are resolved. Thoughts?


Re: Update the document without current version

Posted by Max Ogden <ma...@maxogden.com>.
Hi Alexander,

I think that the reason that force_update/delete_conflicts doesn't exist is
because it's assumed that since HTTP is a stateless protocol that
applications built using Couch will keep state on the client. For instance,
if you update a document Couch will hand you back the new revision so you
don't have to fetch it separately.

In your case you seem to be somehow replacing documents without first
knowing about them, which seems weird to me. Can you shed some more light on
what application level features depend on the force_update/delete_conflicts
API?

Max

On Thu, Oct 13, 2011 at 12:26 AM, Alexander Uvarov <
alexander.uvarov@gmail.com> wrote:

> I would prefer a parameter like "force_update=true" and
> "delete_conflicts=true" to purge all existing versions and conflicts and
> just save new one. Would be useful for cases when user need to overwrite
> existing versions or when conflicts are resolved. Thoughts?
>
> On Oct 13, 2011, at 1:14 PM, Michael Zedeler wrote:
>
> > On 2011-10-13 00:58, Panop Suvaphrom wrote:
> >> I know that it is not possible to update the document without current
> version.
> >>
> >> But anyway, I would like to make sure about this.
> >> Is there a way to update a document without knowing its current
> revision?
> >> I would like to avoid first GETting current version…
> > Did you look at CouchDB document update handlers?
> > --
> > Michael Zedeler
> > 70 25 19 99 | LinkedIn <http://dk.linkedin.com/in/mzedeler> | Twitter <
> http://twitter.com/#%21/mzedeler> | Github <https://github.com/mzedeler>
>
>

Re: Update the document without current version

Posted by Alexander Uvarov <al...@gmail.com>.
I would prefer a parameter like "force_update=true" and "delete_conflicts=true" to purge all existing versions and conflicts and just save new one. Would be useful for cases when user need to overwrite existing versions or when conflicts are resolved. Thoughts?

On Oct 13, 2011, at 1:14 PM, Michael Zedeler wrote:

> On 2011-10-13 00:58, Panop Suvaphrom wrote:
>> I know that it is not possible to update the document without current version.
>> 
>> But anyway, I would like to make sure about this.
>> Is there a way to update a document without knowing its current revision?
>> I would like to avoid first GETting current version…
> Did you look at CouchDB document update handlers?
> -- 
> Michael Zedeler
> 70 25 19 99 | LinkedIn <http://dk.linkedin.com/in/mzedeler> | Twitter <http://twitter.com/#%21/mzedeler> | Github <https://github.com/mzedeler>


Re: Update the document without current version

Posted by Michael Zedeler <mi...@zedeler.dk>.
On 2011-10-13 00:58, Panop Suvaphrom wrote:
> I know that it is not possible to update the document without current version.
>
> But anyway, I would like to make sure about this.
> Is there a way to update a document without knowing its current revision?
> I would like to avoid first GETting current version…
Did you look at CouchDB document update handlers?
-- 
Michael Zedeler
70 25 19 99 | LinkedIn <http://dk.linkedin.com/in/mzedeler> | Twitter 
<http://twitter.com/#%21/mzedeler> | Github <https://github.com/mzedeler>

Re: Update the document without current version

Posted by Zachary Zolton <za...@gmail.com>.
Do you mean Update Handlers?

http://wiki.apache.org/couchdb/Document_Update_Handlers

On Wed, Oct 12, 2011 at 5:58 PM, Panop Suvaphrom <PS...@vizrt.com> wrote:
> Hi,
>
> I know that it is not possible to update the document without current version.
>
> But anyway, I would like to make sure about this.
> Is there a way to update a document without knowing its current revision?
> I would like to avoid first GETting current version…
>
> Thanks a million,
>
> Aun
>