我在 MongoDB 中有一个结构,数组中包含不同数量的项目,称为“items”。为了进行搜索,我使用以下命令,该命令首先将内容转换为字符串,就像在 this.items 中一样,根据对象的不同,有不同的结构:
db.getCollection('docs').find.('JSON.stringify(this.items[0].value).toLowerCase().indexOf("text")!=-1')
Run Code Online (Sandbox Code Playgroud)
我的问题是,由于我不知道每个文档的项目数量,我必须使用通配符作为 this.items[*].value,但它不起作用。
有谁知道任何解决方案,或者对此有其他想法?