0

I have a collection like

{

"email" : "sh@Gmail.com"

}

My query should be like , it has to find matching email irrespective of case whether its capital or small but it should match exactly.

In sql we will do like where Lower(strEmail) = Lower(@emailParameterPassed) to satisfy this same.

UPDATE

I got it here. Thanks

How to achieve this in mongoDb?

I am using c# native driver with mongoDb ?

Community
  • 1
  • 1
shanmugharaj
  • 3,814
  • 7
  • 42
  • 70

1 Answers1

1

Nonetheless the answer you are duplicating will give you a correct result, it is not a good idea to do queries like this. Why should you use regex (without indexes ) if you can use normal equal and take advantage of indexes?

There is no difference between sh@Gmail.com and sh@gmail.com so why not to store them in a canonical form in the first place and then to use normal search. To change all the documents, you can refer to my previous answer.

Community
  • 1
  • 1
Salvador Dali
  • 214,103
  • 147
  • 703
  • 753