Giter Club home page Giter Club logo

Comments (8)

sendtopms avatar sendtopms commented on August 22, 2024

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.

benoitc avatar benoitc commented on August 22, 2024

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.

sendtopms avatar sendtopms commented on August 22, 2024

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.

benoitc avatar benoitc commented on August 22, 2024

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.

sendtopms avatar sendtopms commented on August 22, 2024

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.

benoitc avatar benoitc commented on August 22, 2024

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.

sendtopms avatar sendtopms commented on August 22, 2024

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.

benoitc avatar benoitc commented on August 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.