Consider this example:
f = {'a': 'b'}
col.insert(f)
print f
, where col
is a mongodb collection.
The above code will print something among the lines of:
{'a': 'b', '_id': ObjectId('5278bc183e8b1310247e047b')}
I know why mongo needs to add the _id
field when inserting the document into the collection, but I don't understand why it has to modify the dictionary I pass as an argument. I would like my dictionary f
to remain unmodified.
I know I can just del f['_id']
after the insert, but is there any argument I can pass to insert
that will make it not modify my dict?