Comments (8)
For ex. Futon result of my m/r query is
{"total_rows":1,"offset":0,"rows":[
{"id":"0ef3751ea0dbc32513e78dc46a1c4129","key":"2","value":{"title":"111","slug":"2","body":" dsfkjs sdksj ks ds","imageurl":"krish2.jpg"}}
]}
Couchdb result is
{1,0,
[{<<"total_rows">>,1},{<<"offset">>,0}],
[{<<"0ef3751ea0dbc32513e78dc46a1c4129">>,<<"2">>,
{[{<<"title">>,<<"111">>},
{<<"slug">>,<<"2">>},
{<<"body">>,<<" dsfkjs sdksj ks ds">>},
{<<"imageurl">>,<<"krish2.jpg">>}]}}]}
from couchbeam.
Could you paste the code you use to get results ? Also I'm not sure how do you get thse results. Afaik couchbeam_view:fetch_view will decoded json view without any parsing and couchbeam_view:parse_view will parse it to extract total_rows & co. Let me know.
from couchbeam.
this is my code
query_view(Key) ->
DVName = {"_blog", "withattachments"},
Resp = couchbeam_utils:query_view(DVName, Key),
Resp.
couchbeam_utils:query_view is here
query_view(DVName, []) ->
Attrs = [{"key1",<<>>}],
io:format("Attr is pn", [Attrs]),
ViewPid = couchbeam_db:query_view(couchbeam_client, DVName,Attrs),
Resp = couchbeam_view:parse_view(ViewPid),
io:format("Response is pn", [Resp]),
Resp;
query_view(DVName, Key) ->
Attrs = [{"key",list_to_binary(Key)}],
io:format("Attr is pn", [Attrs]),
ViewPid = couchbeam_db:query_view(couchbeam_client, DVName,Attrs),
Resp = couchbeam_view:parse_view(ViewPid),
io:format("Response is pn", [Resp]),
Resp.
from couchbeam.
so if you use parse_view yu get the answer in a tuple :
{TotalRows, Offset, Meta, Rows};
Where meta is empty in case of normal view or contain infos from c-l or others. If you just want the view decoded but in the form you get from futon you have to use fetch_view function.
I'm not sure what is the real problem anyway ?
from couchbeam.
It is fine but what I found in "rows", it is tuple of proplists "{[{". If it is just proplists, it is easy to avoid one more translation in client side. In the above snippet
{[{<<"title">>,<<"111">>},
{<<"slug">>,<<"2">>},
{<<"body">>,<<" dsfkjs sdksj ks ds">>},
{<<"imageurl">>,<<"krish2.jpg">>}]}
I needed to detuple to access it in the erldtl template engine.
Thanks for the response.
from couchbeam.
Yes I know :( That the only way currently with coiuchdb mochijson to know this is an object and it seem all erlang json libraries do the same. For object some add obj in tuple ({obj, [{ ...) other use struct. That's a pb in erlang. MAybe a pluging in erlydtl could do the trick anyway.
from couchbeam.
Thanks. I can deal with this issue in the erlang client, though it is trivial, i wanted to check if it is addressable. Thanks again.
from couchbeam.
after discussing aroud, it seems the only way in erlang to detect object. So for now I'm closing. Feel free to reopen the bug if you think there is another solution. Thanks for your feedback anyway.
from couchbeam.
Related Issues (20)
- Hackney version is broken with hex HOT 3
- relax hackney version HOT 1
- missing get_config, set_config, delete_config HOT 3
- Hex release of 1.4.2 broken (for Elixir, at least) HOT 2
- Streaming changes timeout after 10 seconds when "since=now" and no changes occur within 10 seconds
- Elixir 1.4 warning package variable does not exists expanding to package() HOT 1
- Publish Couchbeam 1.6.4 on hex? HOT 1
- Future scope of the project HOT 1
- Make hex the default branch HOT 1
- Failed to sove dependency idna HOT 1
- Hackney application failed to start HOT 1
- Mango query _find support
- Authorization options HOT 1
- hmac/3 getting depracated on OTP24 HOT 1
- performance issue HOT 1
- add support for latest APIS in couchdb
- update README HOT 3
- add CI
- No Makefile found HOT 2
- Database disconnect throws unmatched clause error on gen_changes HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from couchbeam.