Skip to content

Instantly share code, notes, and snippets.

@yannski
Created June 18, 2010 16:16
Show Gist options
  • Save yannski/443847 to your computer and use it in GitHub Desktop.
Save yannski/443847 to your computer and use it in GitHub Desktop.
User.where(:age.gt => 27).sort(:age).all,
User.where(:age.gt => 27).sort(:age.desc).all,
User.where(:age.gt => 27).sort(:age).limit(1).all
class User
include MongoMapper::Document
scope :johns, where(:name => 'John')
scope :bills, :name => 'Bill'
scope :by_name, lambda { |name| where(:name => name) }
def self.by_tag(tag)
where(:tags => tag)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment