<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EstiloCorreo17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 3.0cm 70.85pt 3.0cm;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=ES-MX link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US>Hi every one, <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>I was wondering how CB treats the database array fields,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>If I have for example a postgres script like this one:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'>CREATE TABLE users (<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'> id PRIMARY KEY, <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'> name varchar(50),<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'> emails varchar(50) []<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'>)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>In CB a model like this:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'>-module(users, [Id, Name, Emails]).<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>So I have inserted a record in the database and it looks as follow:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'>Id name emails<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'>1 Will <a href="mailto:%7bwill@gmail.com">{will@gmail.com</a>, <a href="mailto:will89@gmail.com">will89@gmail.com</a>, <a href="mailto:will2014@hotmail.com">will2014@hotmail.com</a>}<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>When I do a</span><span lang=EN-US style='font-family:Consolas'> bossdb:find(users, []) </span><span lang=EN-US>for the field emails I got</span><span lang=EN-US style='font-family:Consolas'> <<"{<a href="mailto:will@gmail.com">will@gmail.com</a>, <a href="mailto:will89@gmail.com">will89@gmail.com</a>, <a href="mailto:will2014@hotmail.com">will2014@hotmail.com</a>}">><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>My question is obviously, WTF??? Sorry about that!! How can I parse that!!! To a nicely, normal, pretty, good syntax of CB.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Even I tried from the view to get the value and the value I got is</span><span lang=EN-US style='font-family:Consolas'> <a href="mailto:%7bwill@gmail.com">{will@gmail.com</a>, <a href="mailto:will89@gmail.com">will89@gmail.com</a>, <a href="mailto:will2014@hotmail.com">will2014@hotmail.com</a>} </span><span lang=EN-US>in the view</span><span lang=EN-US style='font-family:Consolas'><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'>test_array('GET', []) -><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'> L = boss_db:find(test, []),<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'> [{_, _, Emails} | R] = L,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'> {ok, [{emails, Emails}]}.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>For the view <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'><ul><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'>{% if emails %}<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'> {{ emails }}<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'>{% else %}<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'> <li>Nothing to do.</li><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'>{% endif %}<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'></ul><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Best regards,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Ivan.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:Consolas'><o:p> </o:p></span></p></div></body></html>