mongodb - pipe.all 不适用于过滤器中的“(”等特殊字符
问题描述
我正在尝试使用 查询 Golang 中的 MongoDB 数据库c.Pipe
,但是尽管我在数据库中有诸如此类的项目,但响应始终为空("name": "test case ( parenthesis )")
。
pipe := c.Pipe([]bson.M{{"$match": bson.M{"name":"("}}})
resp := []bson.M{}
err := pipe.All(&resp)
if err != nil {
//handle error
}
fmt.Println(resp) // Empty resp
解决方案
您应该需要一个正则表达式来查询包含character的名称(
。正则表达式应该是.*\(.*
.
推荐阅读
- math - 实现太阳位置和坐标系转换的近似值的问题
- sql - 使用 SQL 中的 3 个表计算收入 - 费用
- salesforce - 您有未提交的工作待处理。请在调用前提交或回滚
- tensorflow - TensorFlow 数据集“cats_vs_dogs”的预处理
- javascript - Javascript:按下按钮时如何进行淡入淡出转换?
- python - PyVISA 错误:系统资源不足,无法执行必要的内存分配
- bash - 为什么 ssh-keygen 的 -f 标志无法遵循符号链接?
- linux - Shell Script null 检查似乎不起作用
- javascript - 从带有视频的 React 应用动态页面创建带有来自社交媒体片段的视频播放的 twitter 播放器卡
- javascript - 在 Javascript 中使用 fetch 时出现内部服务器和语法错误