猫鼬中的“无法识别的表达式`$regexMatch`”

时间:2021-05-13 17:09:31

标签: mongodb mongoose

我试图将聚合运算符与猫鼬一起使用,但出现以下错误:

<块引用>

“无法识别的表达式 $regexMatch

let data = await Product.aggregate([
            { $match: { product_name: { $regex: /iphone/i } } },
            {
                $project: {
                    product_name: 1,
                    is_starting_match: {
                        $regexMatch: { input: '$product_name', regex: /^iphone/i },
                    },
                    price: {
                        $convert: {
                            input: { $arrayElemAt: ['$stores.storePrice', 0] },
                            to: 'int',
                            onError: 0,
                            onNull: 0,
                        },
                    },
                },
            },
            { $sort: { price: -1 } },
        ]);

0 个答案:

没有答案