Skip to content

Tag: mongodb-java

Mongodb avoid duplicate entries

I am newbie to mongodb. May I know how to avoid duplicate entries. In relational tables, we use primary key to avoid it. May I know how to specify it in Mongodb using java? Answer Use an index with the {unique:true} option. You can also do this across multiple fields. See this section in the docs for more det…