diff options
author | Jay Doane <jaydoane@apache.org> | 2020-01-20 10:49:00 -0800 |
---|---|---|
committer | Jay Doane <jaydoane@apache.org> | 2020-01-20 10:53:41 -0800 |
commit | 256909bd81cb791a3435dc841d8632c9dabbafbd (patch) | |
tree | 7661276ccde84ab460b8051e5f508850bb1a522b | |
parent | ab4eafab0d555881f118b2ab19678872814b5059 (diff) | |
download | couchdb-mango-index-hook.tar.gz |
WIP index hookmango-index-hook
-rw-r--r-- | src/fabric/src/fabric2_db_plugin.erl | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/fabric/src/fabric2_db_plugin.erl b/src/fabric/src/fabric2_db_plugin.erl index fb83ed407..a145c7493 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 |