-
-
Save lynnfaraday/fa59879afaf24e5f13bd4002ce57caf3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ohm' | |
Ohm.redis = Redic.new("CONN_STRING") | |
class Photo < Ohm::Model | |
reference :photo_album, "PhotoAlbum" | |
attribute :name | |
index :name | |
end | |
class PhotoAlbum < Ohm::Model | |
collection :photos, "Photo" | |
attribute :name | |
index :name | |
end | |
def createPhotos(album, num) | |
num.times do |n| | |
p = Photo.create(name: "#{n}", photo_album: album) | |
end | |
end | |
def deletePhotos | |
Photo.all.each { |p| p.delete } | |
PhotoAlbum.all.each { |p| p.delete } | |
end | |
smallAlbum = PhotoAlbum.create(name: "Small") | |
bigAlbum = PhotoAlbum.create(name: "Big") | |
createPhotos(smallAlbum, 100) | |
createPhotos(bigAlbum, 3000) | |
puts "Small #{smallAlbum.photos.count}" | |
puts smallAlbum.photos.map { |p| p.name }.join(" ") | |
puts "Big #{bigAlbum.photos.count}" | |
puts bigAlbum.photos.map { |p| p.name }.join(" ") | |
deletePhotos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment