Skip to content

Instantly share code, notes, and snippets.

@kyanny
Created April 8, 2015 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyanny/f767f34bd19d6318ca15 to your computer and use it in GitHub Desktop.
Save kyanny/f767f34bd19d6318ca15 to your computer and use it in GitHub Desktop.
require 'mongo_mapper'
MongoMapper.database = 'testing'
class User
include MongoMapper::Document
end
class Bookmark
include MongoMapper::Document
belongs_to :user
ensure_index :user_id
end
class Tag
include MongoMapper::Document
belongs_to :user
belongs_to :bookmark
ensure_index :user_id
ensure_index :bookmark_id
ensure_index :user_id => Mongo::ASCENDING, :bookmark_id => Mongo::ASCENDING
end
require 'pp'
pp User.collection.index_information
pp Bookmark.collection.index_information
pp Tag.collection.index_information
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment