Skip to content
Browse files

Changes for the "separate document body and meta" work

GeoCouch needs slight changes to make it work with the
new separated documents, where the documents have a
body and a meta part.

This needs to be merged along with (and all its dependencies):
http://review.couchbase.org/17590

Change-Id: I5429d0839ab56671ee481e517b6608bf14661e76
Reviewed-on: http://review.couchbase.org/18412
Reviewed-by: Chris Anderson <jchris@couchbase.com>
Tested-by: Chris Anderson <jchris@couchbase.com>
  • Loading branch information...
1 parent c4428db commit b89b0294cf6f3c5214dd60a64a67b1f17c6a4408 @vmx vmx committed with jchris Jul 17, 2012
Showing with 11 additions and 7 deletions.
  1. +2 −2 src/geocouch/couch_spatial_updater.erl
  2. +9 −5 test/200-compact.t
View
4 src/geocouch/couch_spatial_updater.erl
@@ -141,10 +141,10 @@ spatial_docs(MapCtx, Docs, EmptyResults) ->
spatial_docs(_MapCtx, [], _EmptyResults, Acc) ->
lists:reverse(Acc);
spatial_docs(MapCtx, [Doc | RestDocs], EmptyResults, Acc) ->
- JsonDoc = couch_doc:to_raw_json_binary(Doc),
+ {DocBody, DocMeta} = couch_doc:to_raw_json_binary_views(Doc),
% NOTE vmx: perhaps should map_doc renamed to something more
% general as it can be used for most indexers
- case mapreduce:map_doc(MapCtx, JsonDoc) of
+ case mapreduce:map_doc(MapCtx, DocBody, DocMeta) of
{ok, FunsResults} ->
% the results are a json array of function map yields like this:
% [FunResults1, FunResults2 ...]
View
14 test/200-compact.t
@@ -133,10 +133,13 @@ compact_spatial_group(DbName, DdocName) ->
add_design_doc(DbName) ->
{ok, Db} = couch_db:open_int(DbName, [admin_user_ctx()]),
DDoc = couch_doc:from_json_obj({[
- {<<"_id">>, <<"_design/foo">>},
- {<<"language">>, <<"javascript">>},
- {<<"spatial">>, {[
- {<<"foo">>, <<"function(doc) { emit({type: \"Point\", coordinates: [0,0]}, doc); }">>}
+ {<<"meta">>, {[
+ {<<"id">>, <<"_design/foo">>}]}},
+ {<<"json">>, {[
+ {<<"language">>, <<"javascript">>},
+ {<<"spatial">>, {[
+ {<<"foo">>, <<"function(doc) { emit({type: \"Point\", coordinates: [0,0]}, doc); }">>}
+ ]}}
]}}
]}),
ok = couch_db:update_docs(Db, [DDoc]),
@@ -150,7 +153,8 @@ insert(DbName) ->
{ok, Db} = couch_db:open_int(DbName, [admin_user_ctx()]),
_Docs = lists:map(
fun(_) ->
- Doc = couch_doc:from_json_obj({[{<<"_id">>, couch_uuids:new()}]}),
+ Doc = couch_doc:from_json_obj(
+ {[{<<"meta">>, {[{<<"id">>, couch_uuids:new()}]}}]}),
ok = couch_db:update_docs(Db, [Doc])
end,
lists:seq(1, 100)),

0 comments on commit b89b029

Please sign in to comment.
Something went wrong with that request. Please try again.