Created
September 2, 2009 19:00
-
-
Save jhancock/179900 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
# encoding: utf-8 | |
require 'mongo' | |
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' | |
port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Connection::DEFAULT_PORT | |
puts "Connecting to #{host}:#{port}" | |
db = Mongo::Connection.new(host, port).db('jon') | |
coll = db.collection('test') | |
puts ">> clear collection jon:test" | |
coll.clear | |
puts "Count of jon:test #{coll.count}" | |
puts ">> insert an object with attribute sample1" | |
string = "hello" | |
puts string | |
puts string.encoding | |
oid = coll.save({'sample1' => string}) | |
doc = coll.find_one() | |
puts doc['sample1'].encoding |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment