我在MongoDB中有以下格式的文件:
product = {
items : Array
}
样品
{
"items": ["bananas","apples","grapes","guavas","pineapples"]
}
我想获取其中一个项的元素包含名为apple
的子字符串的所有文档
理想情况下,数组中的apples
和pineapples
包含子字符串apple
,因此文档应该匹配.
我的try 没有成功
let prods = await Product.find({items: {"$in":["apple"]}); //But not working
如果有更好的方法,我们将不胜感激.
谢谢