我正在尝试搜索当前项目:
我尝试了以下操作:{participants: {userEmail: '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6e1a0b1d1a2e09030f0702400d0103" rel="noreferrer noopener nofollow">[email protected]</a>'}}
但它没有返回任何内容。 我是 mongoDB compass,我在查询历史记录中得到以下内容:
我该如何编写查询来查找突出显示的电子邮件地址?或包含该电子邮件地址的文档。
谢谢。
最佳答案
您的查询期望参与者正是这样的对象:
{userEmail: '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="017564727541666c60686d2f626e6c" rel="noreferrer noopener nofollow">[email protected]</a>'}
您想要做的事情可以通过 dot notation 来实现:
{ 'participants.userEmail': '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5420312720143339353d387a373b39" rel="noreferrer noopener nofollow">[email protected]</a>'}}
关于mongodb - 使用 MongoDB 在子文档中查找项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55923141/