【发布时间】:2020-10-20 18:36:12
【问题描述】:
我有一个 ORDERS 集合,类似于:
_id:5f8e7d8084378609b2dca93f
user_id:"5f8465a777b1814c588521e2"
price:96
city:"Mumbai City"
totalCost:96
_id:5f8e7d8084378609b2dca93f
user_id:"5f8465a777b1814c588521e2"
price:96
city:"Delhi"
totalCost:96
然后在我的 API 中接收数组形式的数据:
driverCity = ['Mumbai', 'Ahmednagar', 'Yavatmal', 'Warud', 'Umred']
现在如何查询我的 ORDERS 集合,然后检查 ORDER.city 是否作为子字符串存在是我的 driverCity 正则表达式变量?这意味着如果ORDER.city 和这个数组中存在像“mumbai”这样的子字符串,我想要那个结果。
【问题讨论】:
标签: node.js mongodb mongoose mongodb-query aggregation-framework