A quick way to implement unique constraints in RavenDB
Often times you might find yourself needing to enforce unique constraints on your entities, well RavenDB does not support this out-of-box but do not despair it is very easy to implement this kind of behaviour.
You can follow these instructions from the official site Bundle: Unique Constraints
although I was not able to get the desired results !!!
So after going through posts on their Google group , I came to a conclusion it would be easier to get my hands dirty and do it myself although Oren insists that his bundle works !
In a nutshell what is needed is dummy document that will have the unique property as an Id e.g “Uniqueconstraintsfirstname.lastname@example.org” and you are all set , well not quite when you need to do multiple properties though.
I came across the article quick-and-dirty-unique-constraints-in-raven-db which does exactly what I needed except that it is for just one property, I then added support for multiple properties.
The code is hosted on My Git Hub page.
Comments are always welcome.