praveenchappa has asked for the wisdom of the Perl Monks concerning the following question:

i am connectig to mongodb server and executing quiries through find() method but i couldnot know whether the quirie executed or not my code is as below

my $conn = MongoDB::Connection->new( host => 'XXXXXXX', port => 27017, username=>'XXXXXX', password=>'XXXXXX', db_name => 'mongotestdb' ); my $database = $conn->get_database( 'mongotestdb' ); my $collection = $database->get_collection( $mongodbcoll); my $i=0; for my $line (@filArr){ my @rows=split(/,(?=(?:[^"]|"[^"]*")*$)/,$line); my $data = $collection->find($row[0]); #row[0]contains mongodb quireie like {name":"studentname1","age":33} #NEED TO VALIDATE HERE WHETHER EXECUTED OR NOT }

Replies are listed 'Best First'.
Re: validate mongoDB result through perl
by blindluke (Hermit) on Nov 17, 2014 at 12:22 UTC

    Look at the last_error() method. Keep in mind that it returns a hash reference.

    my $err = $database->last_error();

    You posted essentially the same question quite recently: how to capture status codes of mongodb in perl. Did you try the suggestions given to you previously?

    - Luke