couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tonysu...@apache.org
Subject couchdb-mango git commit: Return ddoc id and index name
Date Wed, 25 Mar 2015 23:30:48 GMT
Repository: couchdb-mango
Updated Branches:
  refs/heads/2645-return-doc-id [created] 2543fae46


Return ddoc id and index name

We return the ddoc id and index name for easier deletion
from the dashboard. We don't return the full design doc because
we want to hide that abstraction of dealing with design docs from
the user.

FIXES COUCHDB-2645


Project: http://git-wip-us.apache.org/repos/asf/couchdb-mango/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mango/commit/2543fae4
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mango/tree/2543fae4
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mango/diff/2543fae4

Branch: refs/heads/2645-return-doc-id
Commit: 2543fae4683c863d50c18fc041468a64005f8d32
Parents: 8930288
Author: Tony Sun <tony.sun@cloudant.com>
Authored: Wed Mar 25 16:29:31 2015 -0700
Committer: Tony Sun <tony.sun@cloudant.com>
Committed: Wed Mar 25 16:29:31 2015 -0700

----------------------------------------------------------------------
 src/mango_httpd.erl | 5 ++++-
 test/mango.py       | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/2543fae4/src/mango_httpd.erl
----------------------------------------------------------------------
diff --git a/src/mango_httpd.erl b/src/mango_httpd.erl
index 2588a23..28a1578 100644
--- a/src/mango_httpd.erl
+++ b/src/mango_httpd.erl
@@ -20,6 +20,7 @@
 
 -include_lib("couch/include/couch_db.hrl").
 -include("mango.hrl").
+-include("mango_idx.hrl").
 
 
 handle_req(#httpd{} = Req, Db0) ->
@@ -58,6 +59,8 @@ handle_index_req(#httpd{method='POST', path_parts=[_, _]}=Req, Db) ->
     {ok, Idx0} = mango_idx:new(Db, Opts),
     {ok, Idx} = mango_idx:validate(Idx0),
     {ok, DDoc} = mango_util:load_ddoc(Db, mango_idx:ddoc(Idx)),
+    Id = Idx#idx.ddoc,
+    Name = Idx#idx.name,
     Status = case mango_idx:add(DDoc, Idx) of
         {ok, DDoc} ->
             <<"exists">>;
@@ -75,7 +78,7 @@ handle_index_req(#httpd{method='POST', path_parts=[_, _]}=Req, Db) ->
                     ?MANGO_ERROR(error_saving_ddoc)
             end
     end,
-	chttpd:send_json(Req, {[{result, Status}]});
+	chttpd:send_json(Req, {[{result, Status}, {id, Id}, {name, Name}]});
 
 handle_index_req(#httpd{method='DELETE',
         path_parts=[A, B, <<"_design">>, DDocId0, Type, Name]}=Req, Db) ->

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/2543fae4/test/mango.py
----------------------------------------------------------------------
diff --git a/test/mango.py b/test/mango.py
index 79545e1..6dd4077 100644
--- a/test/mango.py
+++ b/test/mango.py
@@ -96,6 +96,8 @@ class Database(object):
         body = json.dumps(body)
         r = self.sess.post(self.path("_index"), data=body)
         r.raise_for_status()
+        assert r.json()["id"] != None
+        assert r.json()["name"] != None
         return r.json()["result"] == "created"
 
     def create_text_index(self, analyzer=None, selector=None, idx_type="text",


Mime
View raw message