mongoose – 如何find其字段“名称”不包含数字的对象

在mongodb模特儿衣服里,有一个叫做名字的集合。

我想查找并列出其名称不包含2016年的所有产品。

例如,名称=“2016年只是牛仔裤黑色外套”或“西部牛仔裤后背裤”

我的代码是:

clothes.find() .and([{name: "black"},{name: {$ne: '2016'}}]) 

它不工作。

我正在考虑使用mongoose聚合,但不知道如何使用它。

它应该是:

 clothes.find({ name: { $not: /2016/ } }) 

如果您需要“黑色”而不是“2016”的名称,请执行以下操作:

 clothes.find({ $and: [{ name: /black/i }, { name: { $not: /2016/ } }] })