Created
February 22, 2011 00:11
-
-
Save brianhempel/837965 to your computer and use it in GitHub Desktop.
Indexing in MongoMapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def build_indexes! | |
ensure_index [["parent_id", Mongo::ASCENDING]] | |
ensure_index [["place_type", Mongo::ASCENDING], ["name", Mongo::ASCENDING]] | |
ensure_index [["ancestor_ids", Mongo::ASCENDING], ["place_type", Mongo::ASCENDING]] | |
end | |
def ensure_index(index_keys) | |
puts "Ensuring index on #{index_keys.map{|i| i[0]}.join(', ')}..." | |
collection.ensure_index index_keys | |
end | |
# it's inside the MM model so MM provides the collection method |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment