Sha256: f1ea88af471400d5b6033ed10dd3e39c2c5bd4e25d28562817bcf699f7918f9c

Contents?: true

Size: 915 Bytes

Versions: 33

Compression:

Stored size: 915 Bytes

Contents

require 'mongo_doc'

class Contact
  attr_accessor :name, :addresses, :interests
end

class Address
  attr_accessor :street, :city, :state, :zip, :phone_number
end

collection = MongoDoc::Collection.new('contacts')
collection.drop

contact = Contact.new
contact.name = 'Hashrocket'
contact.interests = ['ruby', 'rails', 'agile']

address = Address.new
address.street = '320 First Street North, #712'
address.city = 'Jacksonville Beach'
address.state = 'FL'
address.zip = '32250'
address.phone_number = '877 885 8846'
contact.addresses = [address]

collection.save(contact)

in_florida = collection.where('addresses.state' => 'FL')
puts in_florida.first.addresses.first.phone_number
rocket_oid_names = collection.where('name' => /rocket/)
puts rocket_oid_names.first.addresses.first.phone_number
interested_in_ruby = collection.in('interests' => ['ruby'])
puts interested_in_ruby.first.addresses.first.phone_number

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
mongo_doc-0.6.26 examples/simple_object.rb
mongo_doc-0.6.25 examples/simple_object.rb
mongo_doc-0.6.23 examples/simple_object.rb
mongo_doc-0.6.22 examples/simple_object.rb
mongo_doc-0.6.21 examples/simple_object.rb
mongo_doc-0.6.20 examples/simple_object.rb
mongo_doc-0.6.19 examples/simple_object.rb
mongo_doc-0.6.18 examples/simple_object.rb
mongo_doc-0.6.17 examples/simple_object.rb
mongo_doc-0.6.16 examples/simple_object.rb
mongo_doc-0.6.15 examples/simple_object.rb
mongo_doc-0.6.14 examples/simple_object.rb
mongo_doc-0.6.13 examples/simple_object.rb
mongo_doc-0.6.12 examples/simple_object.rb
mongo_doc-0.6.11 examples/simple_object.rb
mongo_doc-0.6.10 examples/simple_object.rb
mongo_doc-0.6.9 examples/simple_object.rb
mongo_doc-0.6.8 examples/simple_object.rb
mongo_doc-0.6.7 examples/simple_object.rb
mongo_doc-0.6.6 examples/simple_object.rb