2017-04-07 213 views
-2

我有以下JSON。我想将它作为Json存储在MongoDB中并进行查询。我该怎么做?如何在MongoDB中查询JSON

JSON

{ 
"id": 4, 
"user": { 
     "firstname":"Finn", 
     "lastname":"Balor", 
     "email":["[email protected]","[email protected]"], 
     "password":"whateverHisTaglineIs", 
     "address":{ 
     "street":"64 victoria street", 
     "country":"UK" 
     } 
    } 
} 

我这个存储为以下文件

> db.users.insert({id: 4,user: {firstname:"Finn",lastname:"Balor",email:["[email protected]","[email protected]"],password:"whateverHisTaglineIs",address:{street:"64 victoria street", country:"UK"}}}) 

我如何可以查询使用国家作为选择这个记录吗?

回答