Skip to content

Instantly share code, notes, and snippets.

@visnup
Created January 12, 2011 19:36
Show Gist options
  • Save visnup/776732 to your computer and use it in GitHub Desktop.
Save visnup/776732 to your computer and use it in GitHub Desktop.
# breakpoint set inside the integration specs.
# a simple person.posts(true) causes a whole lotta activity still.
(rdb:1) person.posts(true)
mongoid_test['posts'].find({"person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001')}, {})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2dfe965b692c635a000002'), :version=>6}, {}).limit(-1)
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2dfea15b692c635a000004'), :version=>1}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000002'), "versions._id"=>BSON::ObjectId('4d2dfea15b692c635a000004')}, {"$set"=>{"versions.0.updated_at"=>Wed Jan 12 19:35:16 UTC 2011}})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2dfeaa5b692c635a000006'), :version=>2}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000002'), "versions._id"=>BSON::ObjectId('4d2dfeaa5b692c635a000006')}, {"$set"=>{"versions.1.updated_at"=>Wed Jan 12 19:35:16 UTC 2011}})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2dffce5b692c635a000008'), :version=>3}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000002'), "versions._id"=>BSON::ObjectId('4d2dffce5b692c635a000008')}, {"$set"=>{"versions.2.updated_at"=>Wed Jan 12 19:35:16 UTC 2011}})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2dfff35b692c635a00000a'), :version=>4}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000002'), "versions._id"=>BSON::ObjectId('4d2dfff35b692c635a00000a')}, {"$set"=>{"versions.3.updated_at"=>Wed Jan 12 19:35:16 UTC 2011}})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2e00155b692c635a00000c'), :version=>5}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000002'), "versions._id"=>BSON::ObjectId('4d2e00155b692c635a00000c')}, {"$set"=>{"versions.4.updated_at"=>Wed Jan 12 19:35:16 UTC 2011}})
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000002')}, {"$set"=>{"updated_at"=>Wed Jan 12 19:35:16 UTC 2011, "version"=>7, "versions"=>[{"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"Test", "updated_at"=>Wed Jan 12 19:35:16 UTC 2011, "_id"=>BSON::ObjectId('4d2dfea15b692c635a000004'), "version"=>1, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"Test", "updated_at"=>Wed Jan 12 19:35:16 UTC 2011, "_id"=>BSON::ObjectId('4d2dfeaa5b692c635a000006'), "version"=>2, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"Test", "updated_at"=>Wed Jan 12 19:35:16 UTC 2011, "_id"=>BSON::ObjectId('4d2dffce5b692c635a000008'), "version"=>3, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"Test", "updated_at"=>Wed Jan 12 19:35:16 UTC 2011, "_id"=>BSON::ObjectId('4d2dfff35b692c635a00000a'), "version"=>4, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"Test", "updated_at"=>Wed Jan 12 19:35:16 UTC 2011, "_id"=>BSON::ObjectId('4d2e00155b692c635a00000c'), "version"=>5, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"Test", "updated_at"=>Wed Jan 12 19:25:09 UTC 2011, "_id"=>BSON::ObjectId('4d2e02745b692c635a00000e'), "version"=>6, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}]}})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2dfe965b692c635a000003'), :version=>6}, {}).limit(-1)
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2dfea15b692c635a000005'), :version=>1}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000003'), "versions._id"=>BSON::ObjectId('4d2dfea15b692c635a000005')}, {"$set"=>{"versions.0.updated_at"=>Wed Jan 12 19:35:16 UTC 2011}})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2dfeaa5b692c635a000007'), :version=>2}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000003'), "versions._id"=>BSON::ObjectId('4d2dfeaa5b692c635a000007')}, {"$set"=>{"versions.1.updated_at"=>Wed Jan 12 19:35:16 UTC 2011}})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2dffce5b692c635a000009'), :version=>3}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000003'), "versions._id"=>BSON::ObjectId('4d2dffce5b692c635a000009')}, {"$set"=>{"versions.2.updated_at"=>Wed Jan 12 19:35:16 UTC 2011}})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2dfff35b692c635a00000b'), :version=>4}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000003'), "versions._id"=>BSON::ObjectId('4d2dfff35b692c635a00000b')}, {"$set"=>{"versions.3.updated_at"=>Wed Jan 12 19:35:16 UTC 2011}})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2e00155b692c635a00000d'), :version=>5}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000003'), "versions._id"=>BSON::ObjectId('4d2e00155b692c635a00000d')}, {"$set"=>{"versions.4.updated_at"=>Wed Jan 12 19:35:16 UTC 2011}})
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000003')}, {"$set"=>{"updated_at"=>Wed Jan 12 19:35:16 UTC 2011, "version"=>7, "versions"=>[{"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"OMG I has relations", "updated_at"=>Wed Jan 12 19:35:16 UTC 2011, "_id"=>BSON::ObjectId('4d2dfea15b692c635a000005'), "version"=>1, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"OMG I has relations", "updated_at"=>Wed Jan 12 19:35:16 UTC 2011, "_id"=>BSON::ObjectId('4d2dfeaa5b692c635a000007'), "version"=>2, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"OMG I has relations", "updated_at"=>Wed Jan 12 19:35:16 UTC 2011, "_id"=>BSON::ObjectId('4d2dffce5b692c635a000009'), "version"=>3, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"OMG I has relations", "updated_at"=>Wed Jan 12 19:35:16 UTC 2011, "_id"=>BSON::ObjectId('4d2dfff35b692c635a00000b'), "version"=>4, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"OMG I has relations", "updated_at"=>Wed Jan 12 19:35:16 UTC 2011, "_id"=>BSON::ObjectId('4d2e00155b692c635a00000d'), "version"=>5, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"OMG I has relations", "updated_at"=>Wed Jan 12 19:25:09 UTC 2011, "_id"=>BSON::ObjectId('4d2e02745b692c635a00000f'), "version"=>6, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}]}})
[#<Post _id: 4d2dfe965b692c635a000002, created_at: Wed Jan 12 19:18:46 UTC 2011, title: "Test", updated_at: Wed Jan 12 19:35:16 UTC 2011, version: 7, person_id: BSON::ObjectId('4d2dfe965b692c635a000001'), content: nil, author_id: nil, tag_ids: []>, #<Post _id: 4d2dfe965b692c635a000003, created_at: Wed Jan 12 19:18:46 UTC 2011, title: "OMG I has relations", updated_at: Wed Jan 12 19:35:16 UTC 2011, version: 7, person_id: BSON::ObjectId('4d2dfe965b692c635a000001'), content: nil, author_id: nil, tag_ids: []>]
# another call, just to demonstrate how version is incrementing along with updated_at timestamps.
(rdb:1) person.posts(true)
mongoid_test['posts'].find({"person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001')}, {})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2dfe965b692c635a000002'), :version=>7}, {}).limit(-1)
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2dfea15b692c635a000004'), :version=>1}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000002'), "versions._id"=>BSON::ObjectId('4d2dfea15b692c635a000004')}, {"$set"=>{"versions.0.updated_at"=>Wed Jan 12 19:35:29 UTC 2011}})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2dfeaa5b692c635a000006'), :version=>2}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000002'), "versions._id"=>BSON::ObjectId('4d2dfeaa5b692c635a000006')}, {"$set"=>{"versions.1.updated_at"=>Wed Jan 12 19:35:29 UTC 2011}})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2dffce5b692c635a000008'), :version=>3}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000002'), "versions._id"=>BSON::ObjectId('4d2dffce5b692c635a000008')}, {"$set"=>{"versions.2.updated_at"=>Wed Jan 12 19:35:29 UTC 2011}})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2dfff35b692c635a00000a'), :version=>4}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000002'), "versions._id"=>BSON::ObjectId('4d2dfff35b692c635a00000a')}, {"$set"=>{"versions.3.updated_at"=>Wed Jan 12 19:35:29 UTC 2011}})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2e00155b692c635a00000c'), :version=>5}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000002'), "versions._id"=>BSON::ObjectId('4d2e00155b692c635a00000c')}, {"$set"=>{"versions.4.updated_at"=>Wed Jan 12 19:35:29 UTC 2011}})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2e02745b692c635a00000e'), :version=>6}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000002'), "versions._id"=>BSON::ObjectId('4d2e02745b692c635a00000e')}, {"$set"=>{"versions.5.updated_at"=>Wed Jan 12 19:35:29 UTC 2011}})
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000002')}, {"$set"=>{"updated_at"=>Wed Jan 12 19:35:29 UTC 2011, "version"=>8, "versions"=>[{"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"Test", "updated_at"=>Wed Jan 12 19:35:29 UTC 2011, "_id"=>BSON::ObjectId('4d2dfea15b692c635a000004'), "version"=>1, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"Test", "updated_at"=>Wed Jan 12 19:35:29 UTC 2011, "_id"=>BSON::ObjectId('4d2dfeaa5b692c635a000006'), "version"=>2, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"Test", "updated_at"=>Wed Jan 12 19:35:29 UTC 2011, "_id"=>BSON::ObjectId('4d2dffce5b692c635a000008'), "version"=>3, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"Test", "updated_at"=>Wed Jan 12 19:35:29 UTC 2011, "_id"=>BSON::ObjectId('4d2dfff35b692c635a00000a'), "version"=>4, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"Test", "updated_at"=>Wed Jan 12 19:35:29 UTC 2011, "_id"=>BSON::ObjectId('4d2e00155b692c635a00000c'), "version"=>5, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"Test", "updated_at"=>Wed Jan 12 19:35:29 UTC 2011, "_id"=>BSON::ObjectId('4d2e02745b692c635a00000e'), "version"=>6, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"Test", "updated_at"=>Wed Jan 12 19:35:16 UTC 2011, "_id"=>BSON::ObjectId('4d2e02815b692c635a000010'), "version"=>7, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}]}})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2dfe965b692c635a000003'), :version=>7}, {}).limit(-1)
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2dfea15b692c635a000005'), :version=>1}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000003'), "versions._id"=>BSON::ObjectId('4d2dfea15b692c635a000005')}, {"$set"=>{"versions.0.updated_at"=>Wed Jan 12 19:35:29 UTC 2011}})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2dfeaa5b692c635a000007'), :version=>2}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000003'), "versions._id"=>BSON::ObjectId('4d2dfeaa5b692c635a000007')}, {"$set"=>{"versions.1.updated_at"=>Wed Jan 12 19:35:29 UTC 2011}})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2dffce5b692c635a000009'), :version=>3}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000003'), "versions._id"=>BSON::ObjectId('4d2dffce5b692c635a000009')}, {"$set"=>{"versions.2.updated_at"=>Wed Jan 12 19:35:29 UTC 2011}})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2dfff35b692c635a00000b'), :version=>4}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000003'), "versions._id"=>BSON::ObjectId('4d2dfff35b692c635a00000b')}, {"$set"=>{"versions.3.updated_at"=>Wed Jan 12 19:35:29 UTC 2011}})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2e00155b692c635a00000d'), :version=>5}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000003'), "versions._id"=>BSON::ObjectId('4d2e00155b692c635a00000d')}, {"$set"=>{"versions.4.updated_at"=>Wed Jan 12 19:35:29 UTC 2011}})
mongoid_test['posts'].find({:_id=>BSON::ObjectId('4d2e02745b692c635a00000f'), :version=>6}, {}).limit(-1)
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000003'), "versions._id"=>BSON::ObjectId('4d2e02745b692c635a00000f')}, {"$set"=>{"versions.5.updated_at"=>Wed Jan 12 19:35:29 UTC 2011}})
MONGODB mongoid_test['posts'].update({"_id"=>BSON::ObjectId('4d2dfe965b692c635a000003')}, {"$set"=>{"updated_at"=>Wed Jan 12 19:35:29 UTC 2011, "version"=>8, "versions"=>[{"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"OMG I has relations", "updated_at"=>Wed Jan 12 19:35:29 UTC 2011, "_id"=>BSON::ObjectId('4d2dfea15b692c635a000005'), "version"=>1, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"OMG I has relations", "updated_at"=>Wed Jan 12 19:35:29 UTC 2011, "_id"=>BSON::ObjectId('4d2dfeaa5b692c635a000007'), "version"=>2, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"OMG I has relations", "updated_at"=>Wed Jan 12 19:35:29 UTC 2011, "_id"=>BSON::ObjectId('4d2dffce5b692c635a000009'), "version"=>3, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"OMG I has relations", "updated_at"=>Wed Jan 12 19:35:29 UTC 2011, "_id"=>BSON::ObjectId('4d2dfff35b692c635a00000b'), "version"=>4, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"OMG I has relations", "updated_at"=>Wed Jan 12 19:35:29 UTC 2011, "_id"=>BSON::ObjectId('4d2e00155b692c635a00000d'), "version"=>5, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"OMG I has relations", "updated_at"=>Wed Jan 12 19:35:29 UTC 2011, "_id"=>BSON::ObjectId('4d2e02745b692c635a00000f'), "version"=>6, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}, {"created_at"=>Wed Jan 12 19:18:46 UTC 2011, "title"=>"OMG I has relations", "updated_at"=>Wed Jan 12 19:35:16 UTC 2011, "_id"=>BSON::ObjectId('4d2e02815b692c635a000011'), "version"=>7, "person_id"=>BSON::ObjectId('4d2dfe965b692c635a000001'), "tag_ids"=>[]}]}})
[#<Post _id: 4d2dfe965b692c635a000002, created_at: Wed Jan 12 19:18:46 UTC 2011, title: "Test", updated_at: Wed Jan 12 19:35:29 UTC 2011, version: 8, person_id: BSON::ObjectId('4d2dfe965b692c635a000001'), content: nil, author_id: nil, tag_ids: []>, #<Post _id: 4d2dfe965b692c635a000003, created_at: Wed Jan 12 19:18:46 UTC 2011, title: "OMG I has relations", updated_at: Wed Jan 12 19:35:29 UTC 2011, version: 8, person_id: BSON::ObjectId('4d2dfe965b692c635a000001'), content: nil, author_id: nil, tag_ids: []>]
(rdb:1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment