My logic in function does not allow to duplicate data in normal operation
{"name":"paul", "age":"21"} {"name":"goerge", "age":"21"} {"name":"paul", "age":"44"} {"name":"paul", "age":"21"}
``My function does not allow last one as paul and age 21 is already in database. But when the traffic is high, it is found that that one is also added. To solve this problem, I used compound index as db.test.createIndex({"name":1, "age":1}, {unique:true})
. This does not let to allow another data starting with paul.
Is there any way to stop duplicate data ?