在mongodb中查询具有多个集合的数据

时间:2015-02-03 00:45:55

标签: mongodb

我对mongoDB中的多个集合有疑问。

我的数据库中有3个集合,集合名称是Building,History和basic_amenities。

我的问题是,我想要检索建筑物,历史和basi_amenties的数据到特定的建筑物。我的意思是我想要建筑,历史和basic_amenities的数据。

我想使用聚合概念。是否可以这样做,否则有任何替代方法。

建设:

{
    "_id" : "B1",
    "Sale_type" : "Rental",
    "Building_name" : "swamy",
    "Available_apartments" : {
        "Apartment_num" : "A6",
        "Apartment_num" : "A9"
    },
    "Owner" : [ 
        "sreekanth Buddha", 
        "sreekanthb6@gmail.com"
    ],
    "Address" : {
        "Street" : "blumenstrasse",
        "Plot_no" : "13",
        "City" : "Hamburg",
        "State" : "lower saxony",
        "Country" : "Germany",
        "Postal_code" : "68245"
    },
    "Rental" : {
        "Currency" : "EUR",
        "Rental_price" : "10000",
        "Available_date" : "02.03.2015",
        "Deposit_amount" : "60000 EUR"
    },
    "Total_area" : "1200 sq meters",
    "Apartment_id" : [ 
        {
            "id1" : "A1"
        }, 
        {
            "id2" : "A5"
        }, 
        {
            "id3" : "A7"
        }, 
        {
            "id4" : "A2"
        }, 
        {
            "id5" : "A9"
        }
    ],
    "Features" : {
        "No_of_apartments" : "70",
        "Community_hall" : "1",
        "Garden" : 3,
        "Office_room" : 1,
        "Parking" : "yes",
        "Play_ground" : "yes"
    }
}

历史记录:

"_id" : "H-B1",
    "Property_id" : "B1",
    "Builtyear" : "April 1995",
    "year_of_registration" : [ 
        {
            "year" : ISODate("1995-04-15T23:00:00.000Z"),
            "name" : "krishna malli"
        }, 
        {
            "year" : ISODate("2008-07-16T23:00:00.000Z"),
            "name" : "manoj kumar alluri"
        }, 
        {
            "year" : ISODate("2014-10-29T23:00:00.000Z"),
            "name" : "Ram dev swamy"
        }
    ],
    "Renovate" : [ 
        {
            "1995" : " building painting Renovated"
        }, 
        {
            "2008" : " pipeline system was renovated"
        }, 
        {
            "2014" : " roof was renovated"
        }
    ]
}

**Basic_amenities:**


{
    "_id" : "BA-B1",
    "Property_id" : "B1",
    "hospital " : "5 km",
    "bahn_station" : "6 km ",
    "restaurant" : "4 km",
    "University" : "20 km",
    "police_station" : "8 km",
    "Airport" : "40 km",
    "city_center" : " 5 km",
    "Public_transp_type" : [ 
        {
            "Bus" : "35"
        }, 
        {
            "tram" : "5"
        }, 
        {
            "train_station" : "5km"
        }
    ],
    "keylandmark" : "Altstadt",
    "future_activity" : "church constructing"
}

任何人都可以帮助我如何使用聚合概念查询此数据,否则是否有其他方法?请帮帮我

此致 斯里卡特

0 个答案:

没有答案