Unfortunately, I can't use OIDs. For now, the Guids come from
"elsewhere" and their generation is out of my control. (Data in Mongo
points to data elsewhere.)
I think I can summarize the two working approaches for Guids:
1: Use the Guid's ToByteArray() method, put that into a
MongoDB.Driver.Binary object, and set its SubType to Uuid. Upon
retrieval, use the Binary object's Bytes property to reconstruct the
Guid.
2: Use the Guid's ToString() method. Upon retrieval, pass the string
to Guid's constructor to reconstruct the Guid.
Any major problems with either approach?
On Jan 29, 10:31 am, Michael Dirolf <m...@dirolf.com> wrote:
> I think Seth's suggestion is a good one. The UUID subtype is just for
> storing UUIDs from any source - nothing Python specific there. If
> you're storing UUIDs I'd use that. If you're just looking for a unique
> id I'd check out ObjectId as Sam points out.
>
>
>
> On Fri, Jan 29, 2010 at 1:29 PM, Sam Corder <sa...@codeargyle.com> wrote:
> > I think the uuid sub type is really for the python uuid type and it isn't
> > normally the same number of bytes as a guid. It is probably safer to
> > use UserDefined instead. I'm not sure how querying on it would work out if
> > you need to do that. In that case converting it to hex and storing it as a
> > string might workout better. Also the Oid is pretty well guaranteed to be
> > unique across machines and time so you could look at that as an option too.
> > You can generate your own with the OidGenerator class.
>
> > On Fri, Jan 29, 2010 at 1:13 PM, Seth Edwards <sethaedwa...@gmail.com>
* Not all databases are huge. A 10 gigabyte database is a cakewalk
for a desktop computer, but can still hold a lot of valuable data.
Sometimes developer convenience trumps efficiency when working with
these kinds of databases.
> Ken Egozi.http://www.kenegozi.com/bloghttp://www.delver.comhttp://www.musicglue.comhttp://www.castleproject.orghttp://www.idcc.co.il- הכנס הקהילתי הראשון למפתחי דוטנט - בואו בהמוניכם