Skip to content

Instantly share code, notes, and snippets.

@chischaschos
Created May 6, 2011 19:05
Show Gist options
  • Save chischaschos/959570 to your computer and use it in GitHub Desktop.
Save chischaschos/959570 to your computer and use it in GitHub Desktop.
User.ensure_index [[:email, 1], [:login_token, 1]]
User.ensure_index :api_key
User.ensure_index :updated_at
#TrackedProject.ensure_index :updated_at
#GitTracker.ensure_index :track_at
Project.ensure_index :change_ids
# ({:project_id=>BSON::ObjectId('4dc4304f25faf20bcc000002'),
# :$or=>[
# {:xcreated_at=>{:$gt=>Sat Apr 30 05:00:00 UTC 2011}},
# {:xupdated_at=>{:$gt=>Sat Apr 30 05:00:00 UTC 2011}}]},
# {:project_id=>1, :xupdated_at=>1}).sort(xupdated_at-1xcreated_at-1)
Change.ensure_index [[:project_id, 1], [:xupdated_at, 1], [:xcreated_at, -1]]
Change.ensure_index [[:project_id, 1], [:xupdated_at, 1], [:xupdated_at, -1]]
# ({:$or=>[
# {:xcreated_at=>{:$gt=>Fri May 06 17:49:20 UTC 2011}},
# {:xupdated_at=>{:$gt=>Fri May 06 17:49:20 UTC 2011}}],
# :user_id=>BSON::ObjectId('4dc4304f25faf20bcc000001')}).limit(25).sort(xupdated_at-1xcreated_at-1)
Change.ensure_index [[:user_id, 1], [:xcreated_at, -1]]
Change.ensure_index [[:user_id, 1], [:xupdated_at, -1]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment