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
|
|---|