You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2020/01/20 19:05:38 UTC
[couchdb] branch mango-index-hook created (now 256909b)
This is an automated email from the ASF dual-hosted git repository.
jaydoane pushed a change to branch mango-index-hook
in repository https://gitbox.apache.org/repos/asf/couchdb.git.
at 256909b WIP index hook
This branch includes the following new commits:
new 256909b WIP index hook
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[couchdb] 01/01: WIP index hook
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jaydoane pushed a commit to branch mango-index-hook
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 256909bd81cb791a3435dc841d8632c9dabbafbd
Author: Jay Doane <ja...@apache.org>
AuthorDate: Mon Jan 20 10:49:00 2020 -0800
WIP index hook
---
src/fabric/src/fabric2_db_plugin.erl | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/fabric/src/fabric2_db_plugin.erl b/src/fabric/src/fabric2_db_plugin.erl
index fb83ed4..a145c74 100644
--- a/src/fabric/src/fabric2_db_plugin.erl
+++ b/src/fabric/src/fabric2_db_plugin.erl
@@ -40,6 +40,7 @@ before_doc_update(_, #doc{id = <<?LOCAL_DOC_PREFIX, _/binary>>} = Doc, _) ->
Doc;
before_doc_update(Db, Doc0, UpdateType) ->
+ maybe_update_indexes(Db, Doc0, UpdateType),
Fun = fabric2_db:get_before_doc_update_fun(Db),
case with_pipe(before_doc_update, [Doc0, Db, UpdateType]) of
[Doc1, _Db, UpdateType1] when is_function(Fun) ->
@@ -49,6 +50,25 @@ before_doc_update(Db, Doc0, UpdateType) ->
end.
+maybe_update_indexes(Db, Doc, _UpdateType) ->
+ couch_log:info("~p maybe_update_indexes Db: ~p Doc: ~p", [?MODULE, Db, Doc]),
+ couch_log:info("~p maybe_update_indexes Op: ~p", [?MODULE, op(Doc)]).
+
+
+op(#doc{revs = Revs, deleted = Deleted}) ->
+ case Revs of
+ {0, []} ->
+ create;
+ _ ->
+ case Deleted of
+ true ->
+ delete;
+ false ->
+ update
+ end
+ end.
+
+
after_doc_read(Db, Doc0) ->
Fun = fabric2_db:get_after_doc_read_fun(Db),
case with_pipe(after_doc_read, [Doc0, Db]) of