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'] }