Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: mongodb dynamic filter

by actarus2003 (Novice)
on Nov 09, 2017 at 15:52 UTC ( [id://1203053]=note: print w/replies, xml ) Need Help??


in reply to Re: mongodb dynamic filter
in thread mongodb dynamic filter

First of all thanks to all Monks suggested me the way.

Then i take my dirty own way using yours suggestions ...

my @serchstra; my $ccount=0; for(my $id=0;$id < keys %hfields;$id++){ info("compose search $id ",query_parameters->get("columns[$id][sea +rchable]"),' >',query_parameters->get("columns[$id][search][value]"), +'< ',query_parameters->get("columns[$id][data]")); if(query_parameters->get("columns[$id][searchable]") eq 'true' && defined query_parameters->get("columns[$id][search][value]") & +& query_parameters->get("columns[$id][search][value]") ne '') { my $kvalue=query_parameters->get("columns[$id][search][value]" +); push @serchstra,{ query_parameters->get("columns[$id][data]") + => qr/$kvalue/i}; $ccount++; } } push @{$serchstr{q{$and}}},@serchstra; info("HH0 serchstr is:".Dumper(%serchstr) ."\n---- lengh of serchstra +is: " .scalar @serchstra . " but ccount $ccount"); $serchstr = \%serchstr if($ccount > 0); @ret = $collection->find($serchstr)->fields(\%hfields)->limit(params-> +{length})->skip(params->{start})->all; }

This piece of code work for me, I may have a variabile number of search parameters from datables.net (so i can reuse with different table with different number of columns and different names of columns), without work/hack the datatables callback (not sure can be done in the search).

Now my table with data from mongo, displayed with datatables (server side processing option) and dancer2 can be also filtered foreach columns.

Thanks for yours precious helps.

Stefano

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1203053]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-03-28 11:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found