FAQ
display deleted keys change


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/commit/1709879a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/tree/1709879a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/diff/1709879a

Branch: refs/heads/1994-merge-rcouch
Commit: 1709879ad91b8f3d7891fc2fc4b25875b39e7a6a
Parents: 697f5f0
Author: benoitc <bchesneau@gmail.com>
Authored: Thu Jul 3 10:23:57 2014 +0200
Committer: benoitc <bchesneau@gmail.com>
Committed: Sun Jul 13 14:33:20 2014 +0200

----------------------------------------------------------------------
  src/couch_httpd_changes.erl | 41 ++++++++++++++++++++--------------------
  1 file changed, 20 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/blob/1709879a/src/couch_httpd_changes.erl
----------------------------------------------------------------------
diff --git a/src/couch_httpd_changes.erl b/src/couch_httpd_changes.erl
index af21792..a6d50c3 100644
--- a/src/couch_httpd_changes.erl
+++ b/src/couch_httpd_changes.erl
@@ -244,24 +244,17 @@ view_changes_cb({{Seq, _Key, DocId}, Val},
      case couch_db:get_doc_info(Db, DocId) of
          {ok, DocInfo} ->
              %% get change row
- {Deleted, ChangeRow} = view_change_row(Db, DocInfo, Args),
+ ChangeRow = view_change_row(Db, DocInfo, Args, Removed),

- case Removed of
- true when Deleted /= true ->
- %% the key has been removed from the view but the
- %% document hasn't been deleted so ignore it.
- {ok, Acc};
- _ ->
- %% emit change row
- Callback({change, ChangeRow, Prepend}, ResponseType),
-
- %% if we achieved the limit, stop here, else continue.
- NewLimit = OldLimit + 1,
- if Limit > NewLimit ->
- {ok, {<<",\n">>, NewLimit, Db, Callback, Args}};
- true ->
- {stop, {<<"">>, NewLimit, Db, Callback, Args}}
- end
+ %% emit change row
+ Callback({change, ChangeRow, Prepend}, ResponseType),
+
+ %% if we achieved the limit, stop here, else continue.
+ NewLimit = OldLimit + 1,
+ if Limit > NewLimit ->
+ {ok, {<<",\n">>, NewLimit, Db, Callback, Args}};
+ true ->
+ {stop, {<<"">>, NewLimit, Db, Callback, Args}}
              end;
          {error, not_found} ->
              %% doc not found, continue
@@ -271,9 +264,9 @@ view_changes_cb({{Seq, _Key, DocId}, Val},
      end.


-view_change_row(Db, DocInfo, Args) ->
+view_change_row(Db, DocInfo, Args, Removed) ->
      #doc_info{id = Id, high_seq = Seq, revs = Revs} = DocInfo,
- [#rev_info{rev=Rev, deleted=Del} | _] = Revs,
+ [#rev_info{rev=Rev, deleted=Del0} | _] = Revs,

      #changes_args{style=Style,
                    include_docs=InDoc,
@@ -288,7 +281,13 @@ view_change_row(Db, DocInfo, Args) ->
#rev_info{rev=R} <- Revs]
      end,

- {Del, {[{<<"seq">>, Seq}, {<<"id">>, Id}, {<<"changes">>, Changes}] ++
+ Del = case {Removed, Del0} of
+ {true, _} -> true;
+ {false, true} -> true;
+ _ -> false
+ end,
+
+ {[{<<"seq">>, Seq}, {<<"id">>, Id}, {<<"changes">>, Changes}] ++
       deleted_item(Del) ++ case InDoc of
              true ->
                  Opts = case Conflicts of
@@ -304,7 +303,7 @@ view_change_row(Db, DocInfo, Args) ->
                  end;
              false ->
                  []
- end}}.
+ end}.

  parse_changes_query(Req, Db) ->
      ChangesArgs = lists:foldl(fun({Key, Value}, Args) ->

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 10 | next ›
Discussion Overview
groupcommits @
categoriescouchdb
postedJul 13, '14 at 12:34p
activeJul 13, '14 at 12:34p
posts10
users1
websitecouchdb.apache.org
irc#couchdb

1 user in discussion

Benoitc: 10 posts

People

Translate

site design / logo © 2021 Grokbase