gpt4 book ai didi

mongodb - 在 MongoMapper 中搜索与正则表达式不匹配的字段

转载 作者:可可西里 更新时间:2023-11-01 09:59:44 26 4
gpt4 key购买 nike

在 MongoMapper 中,我可以使用以下查询来搜索基于正则表达式匹配的项目:

Foo.where(:name => /Foo.*/)

如何搜索其 name 字段与 /Foo.*/ 不匹配的项目?

最佳答案

您可以使用 $not

db.customers.find( { name : { $not : /acme.*corp/i } } );

关于mongodb - 在 MongoMapper 中搜索与正则表达式不匹配的字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10751673/

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