假设我things在具有此架构的数据库中:
{
tags: [String]
}
我有这样的tags数组:["tag1", "tag2"]
现在我需要搜索things并只获取那些包含我的标签的数组。
我在这里$where搜索并找到了操作员,但这不是我需要的。
我想知道在 mongo中应该有类似的东西,或者在 mongoose 中应该有类似的东西。有任何想法吗?
db.things.find( { $where: "this.tags.contains(<my tags somehow>)" } );