I wrote some code in an older version of ruby with an older version of
mongo:
I learned the MongoClient no longer existed, so I was able to find just
Mongo::Client.
Here is my new code but the old find statement doesn't work anymore, and I
can't seem to find any documentation on this? It's the find statement that
gives me this error:
/Library/Ruby/Gems/2.0.0/gems/mongo-2.0.6/lib/mongo/operation/result.rb:214:in
`validate!': sort must be an object or array (13513)
(Mongo::Error::OperationFailure)
from
/Library/Ruby/Gems/2.0.0/gems/mongo-2.0.6/lib/mongo/operation/read/query.rb:62:in
`block in execute_message'
from
/Library/Ruby/Gems/2.0.0/gems/mongo-2.0.6/lib/mongo/server/connection_pool.rb:99:in
`with_connection'
from
/Library/Ruby/Gems/2.0.0/gems/mongo-2.0.6/lib/mongo/server/context.rb:63:in
`with_connection'
from
/Library/Ruby/Gems/2.0.0/gems/mongo-2.0.6/lib/mongo/operation/read/query.rb:61:in
`execute_message'
from
/Library/Ruby/Gems/2.0.0/gems/mongo-2.0.6/lib/mongo/operation/read/query.rb:55:in
`execute'
from
/Library/Ruby/Gems/2.0.0/gems/mongo-2.0.6/lib/mongo/collection/view.rb:164:in
`send_initial_query'
from
/Library/Ruby/Gems/2.0.0/gems/mongo-2.0.6/lib/mongo/collection/view/iterable.rb:39:in
`each'
from /Users/jdawg/bin/getmovies.rb:70:in `<main>'
Code:
c = Mongo::Client.new(["aragorn.external.com"], :database => 'prod')
movies = c[:movies]
search = ARGV ? ARGV.join(" "): ""
movies.find({ :$or => [{:name => /#{search}/i}, {:genre => /#{search}/i
}]}).sort(:name).each { |m|
output(m)
}
There is so much different between the old and new, and I can't find any
documentation that compares the old way with whatever is the new way.
Jerry
···
--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Arduino developer
*The most exciting phrase to hear in science - the one that heralds new
discoveries - is not "Eureka!" but "That's funny...".*- Isaac. Asimov
*I*
*f you give someone a program, you will frustrate them for a day; if you
teach them how to program, you will frustrate them for a lifetime. *-
Anonymous
*If writing good code requires very little comments, then writing really
excellent code requires no comments at all!*- Ken Thompson