Reputation: 1
I'm inserting information regarding some files into a MongoDB, among other things a checksum for the file. I want to use the checksum as the _id for the document. How do I do that?
Upvotes: 0
Views: 1059
Reputation: 2821
You would set the _id field explicitly on the document you are storing. For example:
document = {}
document['_id'] = my_id
Please note that the _id value has to be unique for every document. Only store checksum as _id if you know that it will be unique.
Upvotes: 3