-1
mongodb에서 여러 주소의 경우 일반적으로 배열에 주소를 저장합니다.mongodb에서 여러 주소에 대해 사용자 정의 주소 유형에 대한 스키마를 정의하는 방법
address:[
{
"type" : "home",
"primary" : false,
"streetaddress" : "Some",
"locality" : "Farnborough",
"region" : "England",
"formatted" : "Farnborough, United Kingdom",
"country" : "United Kingdom",
"location" : [
-0.752615,
51.2868939
]
},
{
"type" : "business",
"locality" : "London",
"region" : "England",
"formatted" : "The Gherkin, London, United Kingdom",
"primary" : false,
"streetaddress" : "30 St Mary Axe",
"country" : "United Kingdom",
"location" : [
-0.08030649999999999,
51.51449179999999
]
}
]
하지만 키로 특정 주소를 가져 오려면 예. 가정 또는 비즈니스 환경에서는 루프를 통해 배열을 작성해야합니다. 어떤 다른 방법은 당신이 정확하게 배열의 특정 값을 조회하는거야 알고는 상기 값을 알고있는 경우,
{ home_address: { "streetaddress" : "Some", "locality" : "Farnborough", "region" : "England", "formatted" : "Farnborough, United Kingdom", "country" : "United Kingdom", "location" : [ -0.752615, 51.2868939 ] }, business_address : { "locality" : "London", "region" : "England", "formatted" : "The Gherkin, London, United Kingdom", "primary" : false, "streetaddress" : "30 St Mary Axe", "country" : "United Kingdom", "location" : [ -0.08030649999999999, 51.51449179999999 ], }, primary_address : "home_address" }
더 보는 혜택을 할 수있다
는 "차"키 또는, 그것을 다른 방법을 넣어, 당신은에 의해 주소를 얻으려면 기준은 무엇인가? –업데이트 된 질문. 쿼리는이 시나리오에서 json 형식을 작성하는 방법과 관련이 있습니다. 여기서 주소 배열로 루핑하지 않고 "집"주소를 가져 오려고합니다. – jit