Yesterday, I posted on issues I had with MongoDB and Perl. I had done what I had wanted before, I was sure, but my code no longer reflected it, and Shub-Internet was not responding with the answers I desired. If you don't recall:
# This worked to get one value: my $find_one = $collection->find_one( { date => $today }) ; # but if I wanted the whole thing, this didn't work: my $find = $collection->find ;
As it turns out, there's a specific piece of information I did not find, but David Golden of MongoDB set me straight.
# but if I wanted the whole thing, this didn't work: my $find = $collection->find ; my @all = $find->all ; # and in the case I'd want: my %all = map { $_->{ date } => $_ } #map, grep and sort are all-powerful $find->all ; say Dumper \%all ;
This is great. Wonderful, even. I had a failure in understanding, I was open about it, I was corrected, and now I am a better programmer for it.
I do sorta wish I had given Stack Overflow a deeper search first, though....
No comments:
Post a Comment