Exact matching subdocuments is easy, but is there a way to exact match entire document in a collection ?
I have a lot of documents with similar data, and I only need e
i don't think this is possible outright, but a possible solution is to hash the document.
when saving, always create a hash of the document:
var doc = {};
delete doc.hash; // never include the hash itself in the calculation
doc.hash = crypto.createHash('sha256').update(JSON.stringify(doc)).digest();
db.collection.insert(doc);
Then when querying, you can query by hash:
db.collection.find({
hash: hash
})
might be annoying if you frequently do atomic updates on the document.