I’m new to MongoDB. Just wondering:
How do I convert this shell command to ruby?
db.unicorns.find(null, {name: 1, _id:0});
This gives me an error:
db.collection("unicorns").find(nil, :fields=>["name","_id"=>0])
If you have any tutorial resources as well, would appreciate :).
That should almost work. The error you’re getting is something like this:
right? Just use a Hash for fields instead of an Array:
So it is pretty much a straight transliteration of the JavaScript version.
Sorry, I don’t know of any tutorials on this stuff let alone good ones. I’ve figured it out myself through guess work and extrapolating the JavaScript docs.