Fix database query for use with Mongoid, ActiveRecord

The `exists?` method has distinct meaning in Mongoid and AR.
See http://mongoid.org/en/mongoid/docs/querying.html#queries