That would have to be:
(那必须是:)
db.users.find({"name": /.*m.*/})
or, similar:
(或类似:)
db.users.find({"name": /m/})
You're looking for something that contains "m" somewhere (SQL's ' %
' operator is equivalent to Regexp's ' .*
'), not something that has "m" anchored to the beginning of the string.
(您正在寻找某种在某处包含“ m”的东西(SQL的' %
'运算符等效于Regexp的' .*
'),而不是在字符串开头固定了“ m”的东西。)
note: mongodb uses regular expressions which are more powerful than "LIKE" in sql.
(注意: mongodb使用的正则表达式比sql中的“ LIKE”更强大。)
With regular expressions you can create any pattern that you imagine. (使用正则表达式,您可以创建您想像的任何模式。)
For more info on regular expressions refer to this link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
(有关正则表达式的更多信息,请参见此链接https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…