Commits

Benoit Chesneau committed 6c5c51b

fix doc about attachments and make sure we use a string in open_doc.

Comments (0)

Files changed (3)

README.md

-
-couchbeam 0.3 - 2009 (c) Benoît Chesneau <benoitc@e-engura.org>
----------------------------------------------------------------
-
-**couchbeam** is a simple erlang CouchDB framework. couchbeam provides you a full featured and easy client to access and manage multiple couchdb Nodes.
-
-Couchbeam is under Apache License 2. see LICENSE file for more details.
-
-Full documentation of the project is on this [url](http://benoitc.github.com/couchbeam).
-
-
-
-requirements
-------------
-* Erlang/OTP R12-B or newer (compiler to build, kernel,stdlib,ssl,crypto to run)
-* GNU Make (might actually build with some other make as well)
-* [Etap](http://github.com/ngerakines/etap/) (for testing) 
-
-installation
-------------
-To bulid the application simply run 'make'. This should build .beam, .app
-files and documentation.
-
-Code integrate [lhttpc](http://bitbucket.org/etc/lhttpc/src/) but use your own as well.
-
-To run tests run 'make test'.
-To generate doc, run 'make docs'.

deps/lhttpc/util/make_doc.beam

Binary file modified.

src/couchbeam_db.erl

     open_doc(Db, DocId, []).
 
 open_doc(Db, DocId, Params) ->
-    gen_server:call(db_pid(Db), {open_doc, DocId, Params}, infinity).
+    gen_server:call(db_pid(Db), {open_doc, encode_docid(DocId), Params}, infinity).
    
 %% @spec save_doc(Db::pid(), Doc::json_object()) -> json_object() 
 %% @doc save a do with DocId. 
 %%---------------------------------------------------------------------------
 
  
-%% @spec fetch_attachment(Db::pid(), Doc::json_obj(), 
+%% @spec fetch_attachment(Db::pid(), Doc::string(), 
 %%                  AName::string()) -> iolist()
 %% @doc fetch attachment
-fetch_attachment(Db, Doc, AName) ->
-    fetch_attachment(Db, Doc, AName, false).
+fetch_attachment(Db, DocId, AName) ->
+    fetch_attachment(Db, DocId, AName, false).
 
 
 %% @spec fetch_attachment(Db::pid(), DocId::string(), 
 fetch_attachment(Db, DocId, AName, Streaming) ->
     gen_server:call(db_pid(Db), {fetch_attachment, DocId, AName, Streaming}, infinity). 
 
-%% @spec put_attachment(Db::pid(), DocId::string(),
+%% @spec put_attachment(Db::pid(), DocId::doc(),
 %%      Content::attachment_content(), AName::string(), Length::string()) -> json_obj()
 %% @type attachment_content() = string() |binary() | fun_arity_0() | {fun_arity_0(), initial_state()}
+%% @type doc() = json_obj() | {DocID, Rev}
 %% @doc put attachment attachment, It will try to guess mimetype
 put_attachment(Db, DocId, Content, AName, Length) ->
     ContentType = couchbeam_util:guess_mime(AName),
     put_attachment(Db, DocId, Content, AName, Length, ContentType).
     
-%% @spec put_attachment(Db::pid(), Doc::string(),
+%% @spec put_attachment(Db::pid(), Doc::doc(),
 %%      Content::attachment_content(), AName::string(), Length::string(), ContentType::string()) -> json_obj()
 %% @doc put attachment attachment with ContentType fixed.
 put_attachment(Db, DocId, Content, AName, Length, ContentType) ->
     Line1 = couchbeam:json_decode(list_to_binary(Line)),
     decode_lines(Rest, [Line1, Acc]).
     
-encode_docid(Id) when is_list(Id) ->
-    Id;
+encode_docid(Id) when is_binary(Id) ->
+    binary_to_list(Id);
 encode_docid(Id) ->
-    binary_to_list(Id).
+    Id.
 
 maybe_docid(#db{server=ServerState}, {DocProps}) ->
     #server_state{uuids_pid=UuidsPid} = ServerState,