<分区>
model.find({city: city, sort: 'cityname ASC'}, function(err, cityList){});
上面的代码给出了正确的排序列表,但是每当城市是大写或小写时,如 Coimbatore、bangalore、Chennai,它给出的输出为 Chennai、Coimbatore、bangalore,但我需要像 bangalore、Chennai、Coimbatore 这样的输出.请帮助我获得我想要的输出..并感谢大家..
<分区>
model.find({city: city, sort: 'cityname ASC'}, function(err, cityList){});
上面的代码给出了正确的排序列表,但是每当城市是大写或小写时,如 Coimbatore、bangalore、Chennai,它给出的输出为 Chennai、Coimbatore、bangalore,但我需要像 bangalore、Chennai、Coimbatore 这样的输出.请帮助我获得我想要的输出..并感谢大家..
最佳答案
这是 MongoDB 中的一个错误——据我所知,目前还没有真正的解决方案
更新:我找到了一个变通方法 - 再次存储字符串,仅大写或小写,并按该属性排序:http://futurestud.io/blog/case-insensitive-sorting-with-mongoose-and-mongodb/
关于mongodb - 如何在 sails js 框架中执行不区分大小写的排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26996620/
相关文章:
javascript - 为什么找不到带有 '$all' 修饰符的文档?
algorithm - 哪种排序算法可以更快地进行接近/近似排序?
java - ArrayIndexOutOfBoundsException 对不断增长的 arrayList 进行排序
orm - SailsJS、Waterline 使用 select 填充记录
javascript - SailsJS : Where to define db connection to not supported db type (orientdb)? 自定义中间件?
node.js - 我在 nodeMailer 中的附件路径不起作用(Sails 应用程序)