我正在尝试在我的mongodb查询中使用正则表达式.根据文档,我可以在我的查询中运行正则表达式,如下所示:
db.customers.find( { name : /^foo.bar/ } );
Run Code Online (Sandbox Code Playgroud)
但有没有办法在文档中存储正则表达式并检索正则表达式与提供的字符串匹配的文档?
示例文档:
{ _id : SomeID , matcher : "/^foo.bar/" }
Run Code Online (Sandbox Code Playgroud)
查询(在我的梦中).
db.customers.find( { matcher : { $matches : "foozbar" } );
Run Code Online (Sandbox Code Playgroud)