I'm developing an application that create permalinks. I'm not sure how save the documents in MondoDB. Two strategies:
ObjectId autogeneration
MongoDB autogenerates the
_id
. I need to create an index on thepermalink
field because I get the information by the permalink. Also I can access to the creation time of the ObjectId, using thegetTimestamp()
method, sodatetime
fields seems to be redundant but if I delete this field I need two calls to MongoDB one to take the information and another to take the timestamp.{ "_id": ObjectId("5210a64f846cb004b5000001"), "permalink": "ca8W7mc0ZUx43bxTuSGN", "data": "a lot of stuff", "datetime": ISODate("2013-08-18T11:47:43.460+-100") }
Generate _id
I generate the
_id
with the permalink.{ "_id": "ca8W7mc0ZUx43bxTuSGN", "data": "a lot of stuff", "datetime": ISODate("2013-08-18T11:47:43.460+-100") }
I not see any advantage to use ObjectIds. Am I missing something?