Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
問題のフィールドの値だけを出力したい(name)。現在、以下を印刷しています。
name
nameHOSTA nameHOSTB
印刷したい
HOSTA HOSTB
クエリ..。
puts collection.find({"environment_name" => role, "type" => "TF"}, {:fields => {"_id" => 0, "name" => 1}}).to_a
私はこのような何かがあなたが望むようになるはずだと思います:
collection.find({"environment_name" => role, "type" => "TF"}, {:fields => {"_id" => 0, "name" =>1}}).each { |item| puts item['name'] }