Skip to content

Instantly share code, notes, and snippets.

View shafferj's full-sized avatar

Justin Shaffer shafferj

View GitHub Profile
### Keybase proof
I hereby claim:
* I am shafferj on github.
* I am shafferj (https://keybase.io/shafferj) on keybase.
* I have a public key whose fingerprint is 79ED 735A 2110 2059 8972 D42D 7C3E B294 FC5F F94E
To claim this, I am signing this object:
Fri Aug 21 15:31:06 setClient: hotpotato_development.events
Fri Aug 21 15:31:06 runQuery: hotpotato_development.events{ _id: "989712574a8c12b80000031d" }
Fri Aug 21 15:31:06 used cursor: BtreeCursor _id_
Fri Aug 21 15:31:06 query hotpotato_development.events ntoreturn:0 reslen:1041 nreturned:1 0ms
Fri Aug 21 15:31:17 connection accepted from 127.0.0.1:46479 #7
Fri Aug 21 15:31:17 setClient: hotpotato_development.$cmd
Fri Aug 21 15:31:17 runQuery: hotpotato_development.$cmd{ ismaster: 1 }
Fri Aug 21 15:31:17 run command hotpotato_development.$cmd { ismaster: 1 }
Fri Aug 21 15:31:17 query hotpotato_development.$cmd ntoreturn:1 reslen:87 nreturned:1 0ms
Fri Aug 21 15:31:17 setClient: hotpotato_development.events
>> cursor = User.collection.find({},{:fields=>nil, :offset=>0, :limit=>1, :sort=>{:$natural=>1}})
=> #<XGen::Mongo::Driver::Cursor:0x5f1838 @query=#<XGen::Mongo::Driver::Query:0x5f1888 @hint=nil, @order_by={:$natural=>1}, @number_to_return=1, @number_to_skip=0, @explain=nil, @selector={}, @fields=nil>, @collection=#<XGen::Mongo::Driver::Collection:0x7597c0 @name="users", @db=#<XGen::Mongo::Driver::DB:0x2511e5c @nodes=[["localhost", 27017]], @name="hotpotato_development", @strict=nil, @pk_factory=nil, @slave_ok=nil, @auto_reconnect=nil, @semaphore=#<Object:0x2511e34 @_mutex=#<Mutex:0x25119e8>>, @socket=#<TCPSocket:0x25119c0>, @port=27017, @host="localhost">, @hint=nil>, @db=#<XGen::Mongo::Driver::DB:0x2511e5c @nodes=[["localhost", 27017]], @name="hotpotato_development", @strict=nil, @pk_factory=nil, @slave_ok=nil, @auto_reconnect=nil, @semaphore=#<Object:0x2511e34 @_mutex=#<Mutex:0x25119e8>>, @socket=#<TCPSocket:0x25119c0>, @port=27017, @host="localhost">, @num_to_return=1, @cache=[], @closed=false, @can_call_
the following has been happening, so started to dig into the implementation of find methods:
confirm data in mongo:
> db.users.find()
{"_id" : ObjectId( "f3df7a4a0388833cde000000") , "created_at" : "Thu Aug 06 2009 09:51:47 GMT-0400 (EDT)" , "updated_at" : "Thu Aug 06 2009 09:51:47 GMT-0400 (EDT)" , "email" : "blah"}
{"_id" : ObjectId( "98e17a4ab87e084b55000000") , "created_at" : "Thu Aug 06 2009 09:58:48 GMT-0400 (EDT)" , "updated_at" : "Thu Aug 06 2009 09:58:48 GMT-0400 (EDT)" , "email" : "blah"}
{"_id" : ObjectId( "05e77a4a2b4c347d84000000") , "created_at" : "Thu Aug 06 2009 10:21:57 GMT-0400 (EDT)" , "updated_at" : "Thu Aug 06 2009 10:21:57 GMT-0400 (EDT)"}
{"_id" : ObjectId( "71f27a4a66b0febbc7000000") , "created_at" : "Thu Aug 06 2009 11:10:41 GMT-0400 (EDT)" , "updated_at" : "Thu Aug 06 2009 11:10:41 GMT-0400 (EDT)" , "email" : "test@test.com"}
{"_id" : ObjectId( "4ff87a4a62f037844a000000") , "created_at" : "Thu Aug 06 2009 11:35:43 GMT-0400 (EDT)" , "updated_at" : "Thu Aug 06 2009 11:35:43
>> User.all
ArgumentError: wrong number of arguments (1 for 0)
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/jnunemaker-mongomapper-0.3.1/lib/mongomapper/document.rb:161:in `new'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/jnunemaker-mongomapper-0.3.1/lib/mongomapper/document.rb:161:in `block in find_every'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/jnunemaker-mongomapper-0.3.1/lib/mongomapper/document.rb:161:in `map'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/jnunemaker-mongomapper-0.3.1/lib/mongomapper/document.rb:161:in `find_every'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/jnunemaker-mongomapper-0.3.1/lib/mongomapper/document.rb:62:in `all'
from (irb):1
from /opt/local/bin/irb:12:in `<main>'
>>