Discussion:
[mongodb-dev] Duplicates are being created in MongoDB
j***@gmail.com
2018-04-05 17:37:15 UTC
Permalink
Hi,
I have created a DAO class where I'm using @CompoundIndexes to avoid
duplicates into my DB but still the entries are being populated. Any idea
about how we can avoid it?

Example class:
@Document(collection = "ABC")
@CompoundIndexes({
@CompoundIndex(def = "{'A.B.x':1, 'A.B.y':1}", name =
"compound_index_1"),
@CompoundIndex(def = "{'A.C.k':1, 'A.C.l':1}", name = "compound_index_2")
})
public class XXX{
private A a;
private String dateOfEntry;
private String dateOfUpdate;
}

class A {
private B b;
private C c;
private string status;

}

class B {
private string x;
private string y;
}

class C{
private string k;
private string l;
private string m;
}
--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-dev+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-dev/d71d5579-7212-42fb-afd1-728e41b243e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'Wan Bachtiar' via mongodb-dev
2018-06-13 06:21:36 UTC
Permalink
Hi,

Note that questions related to the use of MongoDB (i.e. your question) are
better sent to mongodb-user group
<https://groups.google.com/forum/#!forum/mongodb-user>. This group
(mongodb-dev) is for discussion for/by/about developers/development/code of
MongoDB.

Please see MongoDB: Unique Indexes
<https://docs.mongodb.com/manual/core/index-unique/> for information
preventing duplicates entry based on unique field(s).

If you have further questions about duplicates, please post a new
discussion on mongodb-user group
<https://groups.google.com/forum/#!forum/mongodb-user> along with
information below:

- MongoDB version.
- Example of MongoDB documents.
- Steps to reproduce the problem.

Regards,

Wan.
​
--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-dev+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-dev/f9ef9f50-988c-4459-aab4-1cd46393a9f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...