I am trying to get some dummy _id from mongodb, for that i have written the following snippet of code, but it is throwing BulkWriteError.
def get_unique_ids(count):
return db.insert_many([{}] * count).inserted_ids
Exception:
execute_command
raise BulkWriteError(full_result)
pymongo.errors.BulkWriteError: batch op errors occurred
But the following code works perfectly, I wanted to know what is the difference between the two.
def get_unique_ids(count):
return db.insert_many([{} for i in range(count)]).inserted_ids