简体   繁体   中英

How do you perform a Case-Insensitive query in node.js implementations of mongodb?

I have a collection containing usernames. If a user searches for "joe", I want it to return "Joe", and any case-different variants (ie "jOe", etc.).

I'm using monk to implement mongodb queries in my node.js application - but the documentation has no mention of case insensitive queries, nor does it have any implementation of collations.

I am aware that regex can be used (and works), but it seems to go against the advice of the mongo documentation. Is there a regexless way of doing this in node.js implementations of MongoDB?

I'm unsure as to how I would implement a query like this - Any help would be appreciated.

MongoDB 支持文本搜索- 只要该字段具有适当的索引,您就可以利用支持caseSensitive选项的$text运算符。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM