public
Created

  • Download Gist
environment
1 2 3 4 5 6 7 8 9 10 11 12 13
ubuntu 10.04
mongodb db version v2.0.2, pdfile version 4.5
ruby 1.9.2p180
 
i18n-0.6.0
multi_json-1.1.0
activesupport-3.2.2
builder-3.0.0
activemodel-3.2.2
bson-1.6.1
mongo-1.6.1
plucky-0.4.4
mongo_mapper-0.11.0
log
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
**Notice: C extension not loaded. This is required for optimum MongoDB Ruby driver performance.
You can install the extension as follows:
gem install bson_ext
 
If you continue to receive this message after installing, make sure that the
bson_ext gem is in your load path and that the bson_ext and mongo gems are of the same version.
 
MONGODB [DEBUG] Logging level is currently :debug which could negatively impact client-side performance. You should set your logging level no lower than :info in production.
MONGODB (0ms) admin['$cmd'].find({:ismaster=>1}).limit(-1)
MONGODB (0ms) test-db['users'].remove({})
MONGODB (0ms) test-db['users'].update({:_id=>BSON::ObjectId('4f6f0c3e121d923a61000001')}, {"_id"=>BSON::ObjectId('4f6f0c3e121d923a61000001'), "id"=>"1024", "name"=>"me"})
MONGODB (0ms) test-db['users'].find({}).limit(-1)
#<User _id: BSON::ObjectId('4f6f0c3e121d923a61000001'), id: "1024", name: "me">
MONGODB (0ms) test-db['users'].remove({:_id=>{"$in"=>["1024"]}})
MONGODB (0ms) test-db['users'].find({})
[#<User _id: BSON::ObjectId('4f6f0c3e121d923a61000001'), id: "1024", name: "me">]
MONGODB (0ms) test-db['users'].remove({:_id=>BSON::ObjectId('4f6f0c3e121d923a61000001')})
MONGODB (0ms) test-db['users'].find({})
[]
mongomapper_id_poc.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
require 'mongo_mapper'
 
l = Logger.new(STDOUT)
 
MongoMapper.connection = Mongo::Connection.new('localhost', 27017, :logger => l)
MongoMapper.database = 'test-db'
 
class User
include MongoMapper::Document
 
key :id, String
key :name, String
end
 
User.delete_all
 
User.create(:id => 1024, :name => 'me')
 
p user = User.first
 
user.delete
 
p User.all
 
User.delete_all(:_id => user._id)
 
p User.all

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.