Skip to content

Instantly share code, notes, and snippets.

@MichaelXavier
Created July 2, 2010 17:16
Show Gist options
  • Save MichaelXavier/461629 to your computer and use it in GitHub Desktop.
Save MichaelXavier/461629 to your computer and use it in GitHub Desktop.
# Hive::Client is a mysql data store with datamapper, Client is a mongo data store with mongomapper
hive_client_ids = Hive::Client.all(:fields => [:hive_id]).collect(&:hive_id)
=> [16, 26, 50, 52, 53, 54, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109]
# ~ (0.000074) SELECT `id` FROM `clients` ORDER BY `id`
Client.all(:hive_id => 16)
=> []
# MONGODB crystalmetrics_development['clients'].find({:hive_id=>16}, {})
Client.all.find {|c| c.hive_id == 16}
=> #<Client name: "ccghouse", created_at: Wed, 30 Jun 2010 22:18:38 UTC +00:00, updated_at: Wed, 30 Jun 2010 22:18:38 UTC +00:00, hive_id: 16, _id: BSON::ObjectID('4c2bc29fe8278e2777000001')>
# MONGODB crystalmetrics_development['clients'].find({}, {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment