'Strength parameter in collation not woking in in Mongoose

I would like to use mongoose in order to send a query to get data but it has to be case insensitive. I'm doing this:

model.find({ name: /etoile/i }).sort({ popularity: -1 })
    .collation({ locale: 'fr', strength: 1 })

I want to get data that contains etoile and étoile but it doesn't seems to work...



Solution 1:[1]

this does not work modelSchema.index({ name: 1 }),

you can try this code out, I just tried it and it worked

User.findOne({email:req.body.email}).collation( { locale: "en", strength: 2 })

or going by your code just use this

model.find({ name: /etoile/i }).collation({ locale: 'fr', strength: 1 }) then sort it after the selection from the model

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Afolabi Oladipo