[Mojolicious] Mojo:;Pg

34 views
Skip to first unread message

Jan Eskilsson

unread,
Apr 2, 2018, 3:54:49 PM4/2/18
to mojol...@googlegroups.com
Hi everyone


Im new to Mojolicious and I'm still learning perl. I have a project to do a proptotype for a specialized webshop that will contain stockitem that are individuals and needs to be stored with unique information and pictures for each item. To start with it will be around 5.6 miällion unique items to search through.

So i was thinking to use something like this, for the queries in the models, from the help;

$db->select(some_table => ['foo'] => {bar => 'yada'} => sub {
  my ($db, $err, $results) = @_;
  ...
});
Mojo::IOLoop->start unless Mojo::IOLoop->is_running;

So i wonder a bit what is the best design pattern to get the massaged content of the $results to my controller ?

Thank you in advance !

Best Regards
Jan

--
Titles mean nothing.  The one with a servant's heart is the leader.
 
Please consider the environment before you print this email.
 
(1) The contents of this transmission are privileged and confidential and intended solely for the use of the addressee. Any disclosure, distribution or copying of the contents, other than by the addressee, is strictly prohibited. If you receive this transmission in error, please notify us immediately and destroy the material received.
(2) All incoming and outgoing emails and any attachments are subjected to a virus scanner and are believed to be free of any virus, or any other defect which might affect any computer or IT system into which they are received and opened. Therefore, it is the responsibility of the recipient to ensure that they are virus free and no responsibility is accepted by Jan Eskilsson  for any loss or damage arising in any way from receipt or use thereof.

sri

unread,
Apr 2, 2018, 4:04:25 PM4/2/18
to Mojolicious
Make a method that returns a promise.

    package MyApp::Controller::SomeThingy;

    sub whatever {
      my $self = shift;
      $self->some_model->search_something_p(...)->then(sub {
        my $results = shift;
        $self->render('some_template', results => $results);
      });
    }

P.S.: I like to use the *_p naming convention to indicate a promise returning method.

--
sebastian

sri

unread,
Apr 2, 2018, 4:05:02 PM4/2/18
to Mojolicious
(1) The contents of this transmission are privileged and confidential and intended solely for the use of the addressee. Any disclosure, distribution or copying of the contents, other than by the addressee, is strictly prohibited. If you receive this transmission in error, please notify us immediately and destroy the material received.

What?

--
sebastian 

Alberto Mijares

unread,
Apr 2, 2018, 4:22:49 PM4/2/18
to Mojo Users Group
I find this as hilarious as annoying, given the fact that it comes
from a personal email and goes to a distribution list.

Sorry for the unnecessary post.

Jan Eskilsson

unread,
Apr 2, 2018, 4:26:28 PM4/2/18
to mojol...@googlegroups.com
Hi Sebastian


I did a couple of projects for a us based company some time ago and they demanded this text in all emails, I have kept it more or less as a joke :-)

Thank you very much for the tip with the promise, i will dig into that and se how far i get before i need your help again.


Best Regards
Jan

--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+unsubscribe@googlegroups.com.
To post to this group, send email to mojol...@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.



--
Titles mean nothing.  The one with a servant's heart is the leader.
 
Please consider the environment before you print this email.
 
(1) The contents of this transmission are privileged and confidential and intended solely for the use of the addressee. Any disclosure, distribution or copying of the contents, other than by the addressee, is strictly prohibited. If you receive this transmission in error, please notify us immediately and destroy the material received.
Reply all
Reply to author
Forward
0 new messages