vietjtnguyen/annotator — pull request #19 by vietjtnguyen (2014-08-29 02:51:31+00:00)
Title: Fix #18, made name field for image model unique.

Turns out the problem was really stupid. I was upserting based on the SHA1 hash so if the SHA1 hash matched it simply updated the existing entry thus preventing duplicate SHA1 hashes. For good measure I also made the name field unique for images.

At first I though the problem was that indexed fields had to be unique by default. I thought the way to solve that was to not index the `sha` field and instead create a compound index with `sha` and `name`. Eventually I spotted the upsert problem and learned that indexed fields can in fact be duplicate.