I'm in the process of converting my Rails app to use mongodb through mongoid. I have two questions relating to indexes. I think I know the answer, but I want confirmation from someone who has more experience with mongodb.
Let's look at the following example where I have one relational association between Users
and Posts
.
user.rb
class User
has_many_related :posts
end
post.rb
class Post
belongs_to_related :user
end
Now when I look at the indexes created through the MongoHQ interface, I notice the following two:
Key Name:
_id_
Indexed Field:_id
Unique:<blank>
Is the id guaranteed to be unique? If so, why isn't unique set. If not, how can I set this and do I need to?Key Name:
user_id_1
Indexed Field:user_id
Unique:false
Am I correct in assuming the Indexed Field is the field name in the collection? Just want to confirm as Key Name has the_1
after it.