const word = ctx.params.word
userModel.find({"name":{$regex: eval(`/${word}/ig`)}})
如果mongodb或者node版本低了,上面写法很可能不管用,可以采用下面两种写法
title:eval("/"+title+"/ig") // 等同于 title:{$regex:title,$Option:"$ig"}