[erlang-questions] Chicago Boss Array Fields in Models

Ivan Carmenates García co7eb@REDACTED
Fri May 23 22:03:43 CEST 2014

Hi every one, 


I was wondering how CB treats the database array fields,


If I have for example a postgres script like this one:



      id          PRIMARY KEY,           

      name        varchar(50),

      emails      varchar(50) []



In CB a model like this:


-module(users, [Id, Name, Emails]).


So I have inserted a record in the database and it looks as follow:


Id    name    emails

1    Will    {will@REDACTED <mailto:%7bwill@REDACTED> , will89@REDACTED,


When I do a bossdb:find(users, []) for the field emails I got
<<"{will@REDACTED, will89@REDACTED, will2014@REDACTED}">>

My question is obviously,  WTF??? Sorry about that!! How can I parse that!!!
To a nicely, normal, pretty, good syntax of CB.


Even I tried from the view to get the value and the value I got is
{will@REDACTED <mailto:%7bwill@REDACTED> , will89@REDACTED,
will2014@REDACTED} in the view


test_array('GET', []) ->

      L = boss_db:find(test, []),

      [{_, _, Emails} | R] = L,

    {ok, [{emails, Emails}]}.



For the view 



{% if emails %}

    {{ emails }}

{% else %}

   <li>Nothing to do.</li>

{% endif %}




Best regards,




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140523/7bad4977/attachment.htm>

More information about the erlang-questions mailing list