Re: Wrap ObjectId

60 views
Skip to first unread message

Ross Lawley

unread,
Jan 26, 2012, 3:08:06 AM1/26/12
to mongoen...@googlegroups.com
Hi,

Can you give me an example of your use case as I'm not finding this to be the case with 0.5.2 or dev.

The following code passes:

        class Person(Document):
            name = StringField()
            age = IntField()

        Person.drop_collection()

        p = Person(name='Ross')
        p.save()

        self.assertEquals(Person.objects(pk=str(p.id)).count(), 1)

What am I missing?

Ross

On Wed, Jan 25, 2012 at 10:27 PM, Alexander Morano <amo...@gmail.com> wrote:
http://groups.google.com/group/mongoengine-users/browse_thread/thread/856f365b7bf4bf8a/e5dcf69f753f3ff2?lnk=gst&q=objectid#e5dcf69f753f3ff2

What was the reasoning behind allowing pymongo ObjectIds to be put
into the Mongo side instead of just putting them in as strings and
having ME cast them out as ObjectIds?

Currently this adds a little bulk per use to the DB and makes
searching outside of ME difficult.

Cheers.

Alexander Morano

unread,
Jan 27, 2012, 4:29:50 PM1/27/12
to mongoen...@googlegroups.com
Not sure the reply I wrote yesterday ever saw the light of day?

Anywho,

This was a mis-understanding on my part mostly.  I completely understand why you need the ObjectId(" portion (for RTTI).

And obviously Mongo drivers themselves are the ones jamming this into the _id field.

Its just that from a client, like RockMongo, you have to write the queries for the _id field to include the ObjectId(" portion.

That could, ultimately, be something RockMongo, et. al. could resolve (potentially) but it is the explicit nature of what Mongo has in the value for the field.

Cheers.
Reply all
Reply to author
Forward
0 new messages