开发者

Couchdb and Nitrogen

开发者 https://www.devze.com 2023-01-01 02:05 出处:网络
How to add Key/value pairs to existing couchdb document through nitrogen web framework? ecouch:doc_update(DBName,DocI开发者_运维技巧d,DocValue) is not returning true when I was trying to implement.Ar

How to add Key/value pairs to existing couchdb document through nitrogen web framework? ecouch:doc_update(DBName,DocI开发者_运维技巧d,DocValue) is not returning true when I was trying to implement.


Are you doing a proper init of ecouch ? Try to fetch this document first in development console.

To do this use

doc_get/2
doc_get(DatabaseName::string(), DocName::string) -> {ok, Response::json()} | {error,     Reason::term()}

This will show you if you init properly connection if not use init if it returns document try to update its json and update it using.

doc_update/3
doc_update(DatabaseName::string(), DocName::string(), Doc::json()) -> {ok, Response::json()} | {error, Reason::term()}

pattern match it on {ok, _ } = doc_update(.. to see if it will blow up. If it will blow up you can do {error, Reason} = doc_update(... and then just io:format("~p~n", [Reason]), to see the actual reason.

I think you are not doing proper init of ecouch thats all.

ecouch doc: http://code.google.com/p/ecouch/wiki/APIDocumentation

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号