gpt4 book ai didi

node.js - MongoError : Can't canonicalize query: BadValue bad order array [2]

转载 作者:IT老高 更新时间:2023-10-28 13:22:58 25 4
gpt4 key购买 nike

我有一个具有以下文档结构的数据库:

{
"_id" : ObjectId("520bea012ab230549e749cff"),
"Day" : 1,
"Time" : 54,
"State" : "Vermont",
"Airport" : "BTV",
"Temperature" : 39,
"Humidity" : 57,
"Wind Speed" : 6,
"Wind Direction" : 170,
"Station Pressure" : 29.6,
"Sea Level Pressure" : 150
}

我需要为每个“州”找到最高的“温度”(例如,有 100 个带有“州”的文档:“佛蒙特州”)并在此文档中添加条目 'month_high':true (具有最高温度)

这是我的代码:http://pastebin.com/UbACLbSF

但是当我在 shell 中运行程序时,出现以下错误:

MongoError: Can't canonicalize query: BadValue bad order array [2]

最佳答案

你应该传入一个对象,而不是一个数组

cursor.sort({"State": 1, "Temperature": -1});

关于node.js - MongoError : Can't canonicalize query: BadValue bad order array [2],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32015745/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com