Skip to content

Instantly share code, notes, and snippets.

@danhixon
Created November 7, 2009 04:43
Show Gist options
  • Save danhixon/228537 to your computer and use it in GitHub Desktop.
Save danhixon/228537 to your computer and use it in GitHub Desktop.
$ gem list | grep mongo
mongo (0.16)
$ irb
>> require 'mongo'
=> true
>> include Mongo
=> Object
>> db = Connection.new('localhost').db('testingmg')
=> #<Mongo::DB:0x1017ebfb0 @host="localhost", @name="testingmg", @pk_factory=nil, @socket=#<TCPSocket:0x1017ebd08>, @slave_ok=nil, @strict=nil, @semaphore=#<Mutex:0x1017ebe48>, @nodes=[["localhost", 27017]], @auto_reconnect=nil, @port=27017, @logger=nil>
>> coll = db.collection('Person')
=> #<Mongo::Collection:0x1017e3270 @name="Person", @pk_factory=Mongo::ObjectID, @hint=nil, @db=#<Mongo::DB:0x1017ebfb0 @host="localhost", @name="testingmg", @pk_factory=nil, @socket=#<TCPSocket:0x1017ebd08>, @slave_ok=nil, @strict=nil, @semaphore=#<Mutex:0x1017ebe48>, @nodes=[["localhost", 27017]], @auto_reconnect=nil, @port=27017, @logger=nil>>
>> coll.distinct('age')
NoMethodError: undefined method `distinct' for #<Mongo::Collection:0x1017e3270>
from (irb):5
>> #Just to make sure I didn't misspell something:
>> coll.methods.sort
=> ["<<", "==", "===", "=~", "[]", "__id__", "__send__", "b64encode", "class", "clear", "clone", "count", "create_index", "db", "decode64", "decode_b", "display", "drop", "drop_index", "drop_indexes", "dup", "encode64", "enum_for", "eql?", "equal?", "extend", "find", "find_one", "freeze", "frozen?", "group", "hash", "hint", "hint=", "id", "index_information", "insert", "inspect", "instance_eval", "instance_exec", "instance_of?", "instance_variable_defined?", "instance_variable_get", "instance_variable_set", "instance_variables", "is_a?", "kind_of?", "method", "methods", "name", "nil?", "normalize_hint_fields", "object_id", "options", "pk_factory", "private_methods", "protected_methods", "public_methods", "remove", "rename", "respond_to?", "returning", "save", "send", "singleton_methods", "size", "taguri", "taguri=", "taint", "tainted?", "tap", "to_a", "to_enum", "to_s", "to_yaml", "to_yaml_properties", "to_yaml_style", "type", "untaint", "update"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment