<div dir="ltr">Thanks Richard and everyone, <div><br></div><div>I added the ".item" so my view shows: <span style="font-family:monospace,monospace">[% entries.$id.item('time') %] </span>I still don't see any results :(<div><br></div><div>I now see in my terminal the following: <font face="monospace, monospace">Argument "client" isn't numeric in numeric comparison (<=>)</font></div><div>Which from what I can tell from Gabor's great site <a href="https://perlmaven.com/argument-isnt-numeric-in-numeric">https://perlmaven.com/argument-isnt-numeric-in-numeric</a> is some numeric operation problem.</div><div><br></div><div>Do you have any examples of controllers passing Mongo data to views so I can compare?</div></div><div><br></div><div>My code so far - perhaps the controller is the issue?</div><div><blockquote type="cite" style="font-size:12.8px"><div dir="ltr"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><font face="monospace, monospace">sub connect_mongo {</font></div><div><font face="monospace, monospace">    my $client = MongoDB->connect('mongodb://a.<wbr>b.c.d') or die "Error connecting to Mongo";</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">     </span>my $db = $client->get_database( 'lfi-perl' );</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">  </span>return($db);</font></div><div><font face="monospace, monospace">}</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">get '/mongo' => sub {</font></div><div><font face="monospace, monospace">    my $db = connect_mongo();</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">    </span>my $docs = $db->get_collection( 'Test-Collection' );</font></div><div><font face="monospace, monospace"><span style="white-space:pre-wrap">   </span>my $all_docs;</font></div><div><font face="monospace, monospace">     template '<a href="http://show_mongo.tt/" target="_blank">show_mongo.tt</a>', {</font></div><div><font face="monospace, monospace">         'entries' => $all_docs = $docs->find(),</font></div><div><font face="monospace, monospace">     };</font></div><div><font face="monospace, monospace">};</font></div></blockquote></div></blockquote></div><div><br></div><div>Appreciate your help,</div><div><br></div><div>Gavin</div><div><br></div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Best Regards,<br><br>Gavin Colborne<br><br>Managing Director,<br><br>Tele:     0207 193 2014<br>Mobile: 0788 400 4339<br>Skype: gavincolborne<br>Visit: <a href="http://www.littleforest.co.uk/" target="_blank">www.littleforest.co.uk</a><br></div><div dir="ltr"><br></div><div dir="ltr"><a href="http://www.littleforest.co.uk/" style="font-family:"Times New Roman";font-size:medium" target="_blank"><img src="http://www.littleforest.co.uk/wp-content/uploads/2017/02/1.jpg" alt="Little Forest LFi"></a><br></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On 18 October 2017 at 10:13, Richard Jones <span dir="ltr"><<a href="mailto:ra.jones@dpw.clara.co.uk" target="_blank">ra.jones@dpw.clara.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <p>I've been caught by that before. Try <font face="monospace,
        monospace">[% entries.$id.item('_id') %]. For some reason (would
        interested to learn what), TT doesn't seem to be able to cope
        with leading underscores in data structures. You can prove
        entries contains data using:</font></p>
    <font face="monospace, monospace">[% USE Dumper(Indent=1) %]</font><br>
    <font face="monospace, monospace">[% FOREACH id IN entries %]</font><br>
    <font face="monospace, monospace">  <pre>[% Dumper.dump(id)
      %]</pre></font><br>
    [% END %]<br>
    <br>
    or just <font face="monospace, monospace">[% Dumper.dump(entries)
      %]<br>
      <br>
    </font>
    <div class="m_8528612235298964169moz-cite-prefix">On 18/10/2017 06:28, Gavin Colborne
      wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">Hi Dancers,
        <div><br>
        </div>
        <div>I am pretty new to Dancer and really like the light nature
          of the framework.</div>
        <div><br>
        </div>
        <div>I am trying to create a route which will show data from a
          MongoDB collection and struggling with the syntax.</div>
        <div><br>
        </div>
        <div>I have the following in my app:</div>
        <div><br>
        </div>
        <blockquote style="margin:0 0 0 40px;border:none;padding:0px">
          <div>
            <div><font face="monospace, monospace">sub connect_mongo {</font></div>
          </div>
          <div>
            <div><font face="monospace, monospace">    my $client =
                MongoDB->connect('mongodb://a.<wbr>b.c.d') or die "Error
                connecting to Mongo";</font></div>
          </div>
          <div>
            <div><font face="monospace, monospace"><span style="white-space:pre-wrap">    </span>my
                $db = $client->get_database( 'lfi-perl' );</font></div>
          </div>
          <div>
            <div><font face="monospace, monospace"><span style="white-space:pre-wrap">    </span>return($db);</font></div>
          </div>
          <div>
            <div><font face="monospace, monospace">}</font></div>
          </div>
          <div><font face="monospace, monospace"><br>
            </font></div>
          <div>
            <div><font face="monospace, monospace">get '/mongo' =>
                sub {</font></div>
          </div>
          <div>
            <div><font face="monospace, monospace">    my $db =
                connect_mongo();</font></div>
          </div>
          <div>
            <div><font face="monospace, monospace"><span style="white-space:pre-wrap">    </span>my
                $docs = $db->get_collection( 'Test-Collection' );</font></div>
          </div>
          <div>
            <div><font face="monospace, monospace"><span style="white-space:pre-wrap">    </span>my
                $all_docs;</font></div>
          </div>
          <div>
            <div><font face="monospace, monospace">     template '<a href="http://show_mongo.tt" target="_blank">show_mongo.tt</a>',
                {</font></div>
          </div>
          <div>
            <div><font face="monospace, monospace">         'entries'
                => $all_docs = $docs->find(),</font></div>
          </div>
          <div>
            <div><font face="monospace, monospace">     };</font></div>
          </div>
          <div>
            <div><font face="monospace, monospace">};</font></div>
          </div>
          <div><font face="monospace, monospace"><br>
            </font></div>
          <div><font face="monospace, monospace">Then in my view the
              following:</font></div>
          <div><font face="monospace, monospace"><br>
            </font></div>
          <div><font face="monospace, monospace">[% FOREACH id IN
              entries.keys.nsort %]</font></div>
          <div>
            <div><font face="monospace, monospace"> </font></div>
          </div>
          <div>
            <div><font face="monospace, monospace">[% entries.$id._id %]</font></div>
          </div>
        </blockquote>
        <div>
          <div><br>
          </div>
          <div><br>
          </div>
          <div>I am not able to see any data in my view but am also not
            seeing any errors.</div>
          <div><br>
          </div>
          <div>Any examples of getting data from Mongo in Dancer would
            be really helpful.</div>
          <div><br>
          </div>
          <div>Thank you in advance,</div>
          <div><br>
          </div>
          <div>Gavin</div>
          <div><br>
          </div>
          <div><br>
          </div>
          <div><br>
          </div>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br clear="all">
          <div>
            <div class="m_8528612235298964169gmail_signature">
              <div dir="ltr">
                <div>
                  <div dir="ltr">
                    <div>
                      <div dir="ltr">Best Regards,<br>
                        <br>
                        Gavin Colborne<br>
                        <br>
                        Managing Director,<br>
                        <br>
                        Tele:     0207 193 2014<br>
                        Mobile: 0788 400 4339<br>
                        Skype: gavincolborne<br>
                        Visit: <a href="http://www.littleforest.co.uk/" target="_blank">www.littleforest.co.uk</a><br>
                      </div>
                      <div dir="ltr"><br>
                      </div>
                      <div dir="ltr"><a href="http://www.littleforest.co.uk/" target="_blank"><img src="http://www.littleforest.co.uk/wp-content/uploads/2017/02/1.jpg" alt="Little Forest LFi"></a><br>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="m_8528612235298964169mimeAttachmentHeader"></fieldset>
      <br>
      <pre>______________________________<wbr>_________________
dancer-users mailing list
<a class="m_8528612235298964169moz-txt-link-abbreviated" href="mailto:dancer-users@dancer.pm" target="_blank">dancer-users@dancer.pm</a>
<a class="m_8528612235298964169moz-txt-link-freetext" href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" target="_blank">http://lists.preshweb.co.uk/<wbr>mailman/listinfo/dancer-users</a><span class="HOEnZb"><font color="#888888">
</font></span></pre><span class="HOEnZb"><font color="#888888">
    </font></span></blockquote><span class="HOEnZb"><font color="#888888">
    <br>
    <pre class="m_8528612235298964169moz-signature" cols="72">-- 
Richard Jones</pre>
  </font></span></div>

<br>______________________________<wbr>_________________<br>
dancer-users mailing list<br>
<a href="mailto:dancer-users@dancer.pm">dancer-users@dancer.pm</a><br>
<a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" rel="noreferrer" target="_blank">http://lists.preshweb.co.uk/<wbr>mailman/listinfo/dancer-users</a><br>
<br></blockquote></div><br></div>