Skip to content

Instantly share code, notes, and snippets.

@tomykaira
Created March 25, 2012 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomykaira/2193241 to your computer and use it in GitHub Desktop.
Save tomykaira/2193241 to your computer and use it in GitHub Desktop.
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
**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({})
[]
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment