- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
这个查询有什么问题?我试图在 mongodb 服务器上运行它并收到如下错误 - “异常:错误查询:BadValue 未知顶级运算符:$gte”。谁能告诉我这有什么问题吗?
db.scores.aggregate([
{
$match: {
$or: [
{ $gte: [ "$score", 30 ] },
{ $lte: [ "$score", 60 ] }
]
}
},
{
$group: {
_id: "$gamer",
games: { $sum: 1 }
}
}
])
样本数据:
{
"_id" : "545665cef9c60c133d2bce72",
"score" : 85,
"gamer" : "Latern"
}
/* 1 */
{
"_id" : "545665cef9c60c133d2bce73",
"score" : 10,
"gamer" : "BADA55"
}
/* 2 */
{
"_id" : "545665cef9c60c133d2bce74",
"score" : 62,
"gamer" : "BADA55"
}
/* 3 */
{
"_id" : "545665cef9c60c133d2bce75",
"score" : 78,
"gamer" : "l00ser"
}
/* 4 */
{
"_id" : "545665cef9c60c133d2bce76",
"score" : 4,
"gamer" : "l00ser"
}
/* 5 */
{
"_id" : "545665cef9c60c133d2bce77",
"score" : 55,
"gamer" : "FunnyCat"
}
最佳答案
你做错了。应该是:
db.scores.aggregate([
{ "$match": {
"score": { "$gte": 30, "$lte": 60 }
}},
{ "$group": {
"_id": "$gamer",
"games": { "$sum": 1 }
}}
])
这是指定“范围”查询的正确方法,其中实际条件是“和”,因此是“在”指定的操作数之间。
关于javascript - Mongodb - 错误查询 : BadValue unknown top level operator: $gte,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26755391/
这是我的代码 14 20 {"Confirm Email"} 21 在第 17 行我得到错误 Type '{ pathname: string; user: { em
这是我的代码 14 20 {"Confirm Email"} 21 在第 17 行我得到错误 Type '{ pathname: string; user: { em
这个问题已经有答案了: How do I compare strings in Java? (23 个回答) 已关闭 8 年前。 为什么 KeyEvent.getKeyText(0).substrin
我正在尝试 Rust 的新 wasm32-unknown-unknown 目标,我在调用数学函数(例如 sin、cos、exp、atan2)时遇到问题。 cargo .toml: [package]
当我为 spring-boot 创建启动项目时,我在 pom 文件中收到此错误。这只是为了创建一个基本的 Spring Boot 项目 Project build error: Invalid pac
我已经订阅了我想要传输的数据。但不知何故它不起作用。我收到此错误: The property pipe is not available for type "OperatorFunction" 这是我
运行以下查询时。select * from surgerys where to_char(dt_surgery ,'DD-MM-YYYY' ) = to_char('12-02-2012','DD-M
我在运行存储过程时遇到以下异常: com.microsoft.sqlserver.jdbc.SQLServerException:不支持从 UNKNOWN 到 UNKNOWN 的转换。 过程定义如下:
我尝试运行以下代码。顺便说一句,我对 python 和 sklearn 都是新手。 import pandas as pd import numpy as np from sklearn.linear
我已经阅读了关于未知类型的官方文档,但我很难真正理解它是如何工作的。 人们可以在文档中读到:“在没有首先断言或缩小到更具体的类型之前,不允许对未知进行任何操作。” 但如果我有这个功能: const f
我正在尝试在Mac OS中设置Hadoop 2.6.0 我正在关注这篇文章: http://hadoop.apache.org/docs/r2.4.0/hadoop-project-dist/hado
配置 Nexus docker 注册表和代理“dockerhub-proxy”后,如下所述: https://help.sonatype.com/repomanager3/formats/docker
我收到此错误 - “ValueError:未知标签类型:'unknown'” 我已经在网上搜索但无法摆脱这个错误,顺便说一句,我是 python 的新手:) 我的数据有 5 行 22 列,最后一列是标
使用 SHA256 摘要标识符 拉取图像失败 最佳答案 不幸的是,这是 DockerHub 删除 Docker 1.9 守护进程的向后兼容性的副作用。当使用 Docker 1.10 推送图像时,较旧的
我是 postgresql 的新手,正在尝试使用全文搜索 to_tsvector但是我遇到了错误。 SQL 和错误 SELECT to_tsvector('english', 'The quick b
每当我这样做时 npm run watch ,第一次编译工作正常 - 但经过几次编译后,我最终会得到这个错误: 95% emitting unnamed compat pluginError: UNK
在一个新的 Angular 应用程序中,我收到以下错误:Error from chokidar : Error: UNKNOWN: unknown error, watch我已经删除并重新安装 nod
使用 Typescipt 4.x.x 我写了一些代码来实现其他语言 Elm/Rust/Haskell 中常用的 Maybe/Option 类型。 我想写一个可以接受映射类型的通用函数 type MyM
const submitted = useSelector((state) => state.post.submitted) 对于上面的状态。我得到错误: (参数)状态:未知对象的类型为“未知”。 这
我正在尝试将多架构 docker 镜像推送到 docker hub 并遇到错误(在 https://github.com/docker/distribution/issues/3100 处打开了 do
我是一名优秀的程序员,十分优秀!