couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randall Leeds <randall.le...@gmail.com>
Subject couch_db:delete_doc/3
Date Thu, 28 Apr 2011 01:29:35 GMT
couch_db:delete_doc/3 isn't actually used anywhere by any code I could find.

However, I just tried to use it in an etap test and found it a bit strange:

delete_doc(Db, Id, Revisions) ->
    DeletedDocs = [#doc{id=Id, revs=[Rev], deleted=true} || Rev <- Revisions],
    {ok, [Result]} = update_docs(Db, DeletedDocs, []),
    {ok, Result}.

I think that's got to be horribly broken because revs should not be a
list but {Pos, [RevList]}, no?
Something more like this maybe right?

delete_doc(Db, Id, Revisions) ->
    DeletedDocs = [#doc{id=Id, revs={Pos, [Rev]}, deleted=true} ||
{Pos, Rev} <- Revisions],
    {ok, [Result]} = update_docs(Db, DeletedDocs, []),
    {ok, Result}.

I'm not really sure how this was intended to work.
Maybe:

delete_doc(Db, Id, Revisions) ->
    DeletedDocs = [#doc{id=Id, revs=Revs, deleted=true} || Revs <- Revisions],
    {ok, [Result]} = update_docs(Db, DeletedDocs, []),
    {ok, Result}.

Weigh in please :)

Mime
View raw message