I save a hash into MongoDB using the Mongo gem. I then get a BSON::Document back when I query the database in Ruby.
How do I convert the BSON::Document back to the original hash?
doc = { name: 'Steve', hobbies: [ 'hiking', 'tennis', 'fly fishing' ] }
result = collection.insert_one(doc)
steve = collection.find( { name: 'Steve' } ).first
returns:
{"_id"=>BSON::ObjectId('5baf68cd65992f3734f396ab'), "name"=>"Steve", "hobbies"=>["hiking", "tennis", "fly fishing"]}