title: How to select a record from an array in MongoDB collection
body: <p>I'm new to MongoDB.</p>
  
  <p>Just created a collection named as <code>datasets</code> and inserted one big json in it.</p>
  
  <p><strong>Document :</strong></p>
  
  <pre><code>{
     "_id":ObjectId(   "5e1f2b248eebbe6d289d53c6"   ),
     "countries":{
        "country":[
           {
              "area":9596960,
              "cities":{
                 "city":[
                    {
                       "citypopulation":7830000,
                       "cityname":"Shanghai"
                    },
                    {
                       "citypopulation":7000000,
                       "cityname":"Beijing"
                    },
                    {
                       "citypopulation":6218000,
                       "cityname":"HongKong"
                    },
                    {
                       "citypopulation":5770000,
                       "cityname":"Tianjin"
                    },
                    {
                       "citypopulation":4540000,
                       "cityname":"Shenyang"
                    },
                    {
                       "citypopulation":3750000,
                       "cityname":"Wuhan"
                    },
                    {
                       "citypopulation":3580000,
                       "cityname":"Guangzhou"
                    },
                    {
                       "citypopulation":2980000,
                       "cityname":"Chongqing"
                    },
                    {
                       "citypopulation":2830000,
                       "cityname":"Harbin"
                    },
                    {
                       "citypopulation":2810000,
                       "cityname":"Chengdu"
                    },
                    {
                       "citypopulation":2760000,
                       "cityname":"Xian"
                    },
                    {
                       "citypopulation":2500000,
                       "cityname":"Nanjing"
                    },
                    {
                       "citypopulation":2460000,
                       "cityname":"Zibo"
                    },
                    {
                       "citypopulation":2400000,
                       "cityname":"Dalian"
                    },
                    {
                       "citypopulation":2320000,
                       "cityname":"Jinan"
                    },
                    {
                       "citypopulation":2110000,
                       "cityname":"Changchun"
                    },
                    {
                       "citypopulation":2060000,
                       "cityname":"Qingdao"
                    },
                    {
                       "citypopulation":1960000,
                       "cityname":"Taiyuan"
                    },
                    {
                       "citypopulation":1710000,
                       "cityname":"Zhengzhou"
                    },
                    {
                       "citypopulation":1530000,
                       "cityname":"Guiyang"
                    },
                    {
                       "citypopulation":1520000,
                       "cityname":"Kunming"
                    },
                    {
                       "citypopulation":1510000,
                       "cityname":"Lanzhou"
                    },
                    {
                       "citypopulation":1500000,
                       "cityname":"Tangshan"
                    },
                    {
                       "citypopulation":1390000,
                       "cityname":"Anshan"
                    },
                    {
                       "citypopulation":1380000,
                       "cityname":"Qiqihar"
                    },
                    {
                       "citypopulation":1350000,
                       "cityname":"Nanchang"
                    },
                    {
                       "citypopulation":1350000,
                       "cityname":"Fushun"
                    },
                    {
                       "citypopulation":1340000,
                       "cityname":"Hangzhou"
                    },
                    {
                       "citypopulation":1330000,
                       "cityname":"Changsha"
                    },
                    {
                       "citypopulation":1320000,
                       "cityname":"Shijiazhuang"
                    },
                    {
                       "citypopulation":1290000,
                       "cityname":"Fuzhou"
                    },
                    {
                       "citypopulation":1270000,
                       "cityname":"Jilin"
                    },
                    {
                       "citypopulation":1200000,
                       "cityname":"Huainan"
                    },
                    {
                       "citypopulation":1200000,
                       "cityname":"Baotou"
                    },
                    {
                       "citypopulation":1190000,
                       "cityname":"Luoyang"
                    },
                    {
                       "citypopulation":1160000,
                       "cityname":"Urumqi"
                    },
                    {
                       "citypopulation":1110000,
                       "cityname":"Handan"
                    },
                    {
                       "citypopulation":1110000,
                       "cityname":"Datong"
                    },
                    {
                       "citypopulation":1090000,
                       "cityname":"Ningbo"
                    },
                    {
                       "citypopulation":1070000,
                       "cityname":"Nanning"
                    },
                    {
                       "citypopulation":1000000,
                       "cityname":"Hefei"
                    }
                 ]
              },
              "name":"China",
              "population":1210004992
           },
           {
              "area":3287590,
              "cities":{
                 "city":[
                    {
                       "citypopulation":9925891,
                       "cityname":"Mumbai"
                    },
                    {
                       "citypopulation":7206704,
                       "cityname":"NewDelhi"
                    },
                    {
                       "citypopulation":4399819,
                       "cityname":"Calcutta"
                    },
                    {
                       "citypopulation":3841396,
                       "cityname":"Madras"
                    },
                    {
                       "citypopulation":3302296,
                       "cityname":"Bangalore"
                    },
                    {
                       "citypopulation":3145939,
                       "cityname":"Hyderabad"
                    },
                    {
                       "citypopulation":2954526,
                       "cityname":"Ahmadabad"
                    },
                    {
                       "citypopulation":1879420,
                       "cityname":"Kanpur"
                    },
                    {
                       "citypopulation":1624752,
                       "cityname":"Nagpur"
                    },
                    {
                       "citypopulation":1619115,
                       "cityname":"Lucknow"
                    },
                    {
                       "citypopulation":1566651,
                       "cityname":"Pune"
                    },
                    {
                       "citypopulation":1505872,
                       "cityname":"Surat"
                    },
                    {
                       "citypopulation":1458183,
                       "cityname":"Jaipur"
                    },
                    {
                       "citypopulation":1091674,
                       "cityname":"Indore"
                    },
                    {
                       "citypopulation":1062771,
                       "cityname":"Bhopal"
                    },
                    {
                       "citypopulation":1061598,
                       "cityname":"Vadodara"
                    },
                    {
                       "citypopulation":1042740,
                       "cityname":"Ludhiana"
                    },
                    {
                       "citypopulation":1014557,
                       "cityname":"Kalyan"
                    }
                 ]
              },
              "name":"India",
              "population":952107712
           }
        ]
     }
  }
  </code></pre>
  
  <p>I want to know, What types of find operations I can do to select this one json entry for learning purpose..?</p>
  
  <p>I was trying to run below find operation, nothing comes out in result.</p>
  
  <pre><code>db.datasets.find({'name':'China'})
  </code></pre>
  
  <p>Secondly, I've added above json in <code>datasets</code> collections using below command</p>
  
  <pre><code>mongoimport --db admin --collection datasets --file /home/lenny/TransformedJSON.json
  </code></pre>
  
  <p>Its working fine, but I want to fail this command. Becasue I dont want to insert without username and password. How it can be done ?</p>
  
  <p>Can anyone please suggest ..?</p>