所以我的 mongo 数据库中有一些 dbobjects。这是其中一个对象的示例:
{ "_id" : { "$oid" : "525b048580c3fb0d62d2b6fc"} , "city" : "London" , "currentWeather" : [ { "cloudcover" : "25" , "humidity" : "82" , "observation_time" : "08:37 PM" , "precipMM" : "0.0" , "pressure" : "1008" , "temp_C" : "11" , "temp_F" : "52" , "visibility" : "10" , "weatherCode" : "113" , "weatherDesc" : [ { "value" : "Clear"}] , "weatherIconUrl" : [ { "value" : "http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0008_clear_sky_night.png"}] , "winddir16Point" : "W" , "winddirDegree" : "280" , "windspeedKmph" : "19" , "windspeedMiles" : "12"}]}
现在,我需要在我的数据库中获取值低于给定“temp_C”的所有 dbobjects,我使用了这样的东西:
BasicDBObject query = new BasicDBObject("temp_C", new BasicDBObject(">", graden));
但它失败了,我认为这是因为该属性是“currentWeather”的子属性,但我不知道如何解决这个问题。我正在使用java来做到这一点。