Sha256: 4d92169a9c542c95c7811ff0b0e90a00d6567ef4cc6c12369eed43c4117c99f2

Contents?: true

Size: 917 Bytes

Versions: 73

Compression:

Stored size: 917 Bytes

Contents

$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
require 'mongo_mapper'
require 'pp'

MongoMapper.database = 'testing'

class User
  include MongoMapper::Document
  
  key :name, String
  key :tags, Array
end
User.collection.remove # empties collection

User.create(:name => 'John',  :tags => %w[ruby mongo], :age => 28)
User.create(:name => 'Bill',  :tags => %w[ruby mongo], :age => 30)
User.create(:name => 'Frank', :tags => %w[mongo],      :age => 35)
User.create(:name => 'Steve', :tags => %w[html5 css3], :age => 27)

[

  User.all(:name => 'John'),
  User.all(:tags => %w[mongo]),
  User.all(:tags.all => %w[ruby mongo]),
  User.all(:age.gte => 30),

  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,
  User.where(:age.gt => 27).sort(:age).skip(1).limit(1).all,

].each do |result|
  pp result
  puts
end

Version data entries

73 entries across 73 versions & 9 rubygems

Version Path
mongo_mapper-0.13.0.beta2 examples/querying.rb
mongo_mapper-0.13.0.beta1 examples/querying.rb
mongo_mapper-0.12.0 examples/querying.rb
lookout-mongo_mapper-0.11.3 examples/querying.rb
mongo_mapper-0.11.2 examples/querying.rb
jamieorc-mongo_mapper-0.11.1.1 examples/querying.rb
mongo_mapper-0.11.1 examples/querying.rb
mongo_mapper-0.11.0 examples/querying.rb
mongo_mapper-0.10.1 examples/querying.rb
mongo_mapper-0.10.0 examples/querying.rb
mongo_mapper-0.9.2 examples/querying.rb
jonbell-mongo_mapper-0.8.6 examples/querying.rb
mongo_mapper-0.9.1 examples/querying.rb
mongo_mapper-0.9.0 examples/querying.rb
ign-mongo_mapper-0.8.6.2 examples/querying.rb
ign-mongo_mapper-0.8.6.1 examples/querying.rb
ssherman-mongo_mapper-0.8.6 examples/querying.rb
mongo_mapper-0.8.6 examples/querying.rb
mongo_mapper-0.8.5 examples/querying.rb
honkster-mongo_mapper-0.8.4 examples/querying.rb