例如针对记录:
{ title: “abcdefd”
num: 4
}
想要用where条件筛选title字段包含指定子串如"cde"的记录,该如何编写条件呢?
db.collection(‘xxxx’).where({
title: /(.*)?cde(.*)?/i
}).get()
或者
db.collection(‘xxxx’).aggregate()
.addFields({
matched: $.gte([$.indexOfCP([’$title’, ‘cde’]), 0])
})
.match({
matched: !0
.end()
大佬有解答,膜拜