Groups
Groups
Sign in
Groups
Groups
mongodb-user
Conversations
About
Send feedback
Help
[perl] Trying to print all ids. What am I doing wrong?
11 views
Skip to first unread message
Amadeus
unread,
Sep 6, 2010, 10:52:51 AM
9/6/10
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongodb-user
Hi,
I am completely new to MongoDB, so first of all I want to print all
ID's in an existing MongoDB using Perl.
The following script prints
HASH(0x12e2e9f0)
25 times. I would have expected to see 25 different ID's.
Any idea what's wrong?
Best regards,
Amadeus
#!/usr/bin/perl
use MongoDB;
use MongoDB::OID;
my $conn = MongoDB::Connection->new;
my $db = $conn->piwik;
my $visits = $db->visits;
my $all_visit_ids = $visits->find;
while (my $doc = $all_visit_ids->next) {
print $doc . "\n";
}
J Greely
unread,
Sep 6, 2010, 1:45:13 PM
9/6/10
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongodb-user
On Sep 6, 7:52 am, Amadeus <
sha256...@gmail.com
> wrote:
> Any idea what's wrong?
Because you retrieved the entire object as a reference to a hash, not
the Object ID as a string.
> print $doc . "\n";
print $doc->{_id},"\n";
-j
Amadeus
unread,
Sep 6, 2010, 4:20:40 PM
9/6/10
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongodb-user
Thank you very much! =)
Reply all
Reply to author
Forward
0 new messages