gpt4 book ai didi

mongodb - 如何执行不区分大小写的 $in $regex 数组?

转载 作者:可可西里 更新时间:2023-11-01 10:36:40 25 4
gpt4 key购买 nike

我如何使用 $in 通过 mongoose 搜索 mongodb 数据库运算符 $regex使用数组操作,例如 ["/servers/i", "/red hat/i"] .

我想找到类似的东西

Report.find({scanMonth: {$in: result}, os: {$in: REGEX ARRAY},'ip scanMonth os crit', function(err, results) 

我的问题是 <Array>

最佳答案

您需要将这些条件与 $and$or 结合起来,例如:

Report.find({ $and: [ { scanMonth: {$in: result} }, { $or: [ { os: { "$regex": "/servers/i" } }, { os: { "$regex": "/red hat/i" } }  ] } ],'ip scanMonth os crit', function(err, results) 

关于mongodb - 如何执行不区分大小写的 $in $regex 数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55913515/

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