Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Getting ObjectID in Mongo
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Miguel Blauwbloeme  
View profile  
 More options Sep 28 2012, 2:43 am
From: Miguel Blauwbloeme <mblauwblo...@gmail.com>
Date: Thu, 27 Sep 2012 23:43:53 -0700 (PDT)
Local: Fri, Sep 28 2012 2:43 am
Subject: Getting ObjectID in Mongo

Hi all,

I new to mongo and I am searchin on how to get the ObjectID of a document
when I do a query on a certain field in that document ?
Can someone help me with this ?

Thanks
Miguël


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Millman  
View profile  
 More options Sep 28 2012, 8:26 am
From: Sam Millman <sam.mill...@gmail.com>
Date: Fri, 28 Sep 2012 13:26:01 +0100
Local: Fri, Sep 28 2012 8:26 am
Subject: Re: [mongodb-user] Getting ObjectID in Mongo

It depends on the server-side language you are using? Which language are
you intending on programming in?

On 28 September 2012 07:43, Miguel Blauwbloeme <mblauwblo...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kay  
View profile  
 More options Sep 28 2012, 4:00 pm
From: Kay <kay....@10gen.com>
Date: Fri, 28 Sep 2012 13:00:48 -0700 (PDT)
Local: Fri, Sep 28 2012 4:00 pm
Subject: Re: Getting ObjectID in Mongo

Hi Miguel --
when you query on a particular field in that document, is the *_id* field
being returned?  The _id field should contain the ObjectID of the document.

If you don't see the _id field as part of the resulting document, could you
specify the query that you are running?  

Regards,

Kay


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Miguel Blauwbloeme  
View profile  
 More options Oct 2 2012, 4:09 am
From: Miguel Blauwbloeme <mblauwblo...@gmail.com>
Date: Tue, 2 Oct 2012 01:09:09 -0700 (PDT)
Local: Tues, Oct 2 2012 4:09 am
Subject: Re: Getting ObjectID in Mongo

I am using pymongo .
The query I am running is collection.find().

This works fine for showing with a for loop every field I want to see for
the whole database.

Now for every document I want to see the ObjectId so I can run another
query to view only the fields of that document.

Someone can help ?

Miguël

Op vrijdag 28 september 2012 08:43:53 UTC+2 schreef Miguel Blauwbloeme het
volgende:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Miguel Blauwbloeme  
View profile  
 More options Oct 2 2012, 4:16 am
From: Miguel Blauwbloeme <mblauwblo...@gmail.com>
Date: Tue, 2 Oct 2012 01:16:16 -0700 (PDT)
Local: Tues, Oct 2 2012 4:16 am
Subject: Re: Getting ObjectID in Mongo

Forgot to mention
I am using django.

Miguël

Op vrijdag 28 september 2012 08:43:53 UTC+2 schreef Miguel Blauwbloeme het
volgende:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kay  
View profile  
 More options Oct 10 2012, 1:48 pm
From: Kay <kay....@10gen.com>
Date: Wed, 10 Oct 2012 10:48:43 -0700 (PDT)
Local: Wed, Oct 10 2012 1:48 pm
Subject: Re: Getting ObjectID in Mongo

Hi Miguël --

Sorry for the delay but was this what you were trying to do -- access the
_id field which contains the ObjectID?

>>> myRecords = myCollection.find( { }, { '_id': 1 } )
>>> for record in myRecords:

record['_id']

Regards,

Kay


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »