假设我有这个:{"_id":"ENVD","years":[{"year":"2013","avgInstructor":5.144999999999998},{"year":"2012","avgInstructor":5.194436090225564}]}我需要能够找到2012-13年avgInstructor字段的差异。我在想我可以使用$project以某种方式转换键,这将使年份成为键,而avgInstructor评级是值。所以它看起来像这样:{"_id":"ENVD","years":{"2013":5.144999999999998,"2012":5.19443609022
假设我有这个:{"_id":"ENVD","years":[{"year":"2013","avgInstructor":5.144999999999998},{"year":"2012","avgInstructor":5.194436090225564}]}我需要能够找到2012-13年avgInstructor字段的差异。我在想我可以使用$project以某种方式转换键,这将使年份成为键,而avgInstructor评级是值。所以它看起来像这样:{"_id":"ENVD","years":{"2013":5.144999999999998,"2012":5.19443609022