I am on my first experience with noSQL databases, using mongodb. I am using Ruby-2.2.2 with Rails-3.2.22 and mongoid-3.17
I've seen that the Mongoid automatically includes an _id field in the models.
BUT,
Do I need to manually create an index for this field or it is automatically created as it happens with ActiveRecord in relational databases?
How can I see the list of indexes that exists for each model?
To get list of existing indexes you should ask inside mongodb console (
mongo
binary on the localhost):Where
databasename
is database name andcollectionname
is the collection name accordingly. http://docs.mongodb.org/manual/reference/method/db.collection.getIndexes/And yes, mongodb has indexes for _id fields automatically. http://docs.mongodb.org/manual/core/index-single/#single-field-indexes