Reputation: 463
How do I query case insensitive search or where condition.
For Example, I have collection tags
{
_id:"id1",
tag:"abc"
}
{
_id:"id2",
tag:"ABC"
}
If i query ::where('tag','abc')
I am getting the only id1 document. How do I query it as case-insensitive, so that I can retrieve both documents(id1 and id2)?
Any help is highly appreciated.
Upvotes: 1
Views: 1587
Reputation: 463
I found the solution by my self.
I need to use like operator without pattern matching (%) symbol.
ModelName::where('tag','like','abc');
This will return both documents ( id1,id2).
Please let me know if there is any better solution exists for this query.
Upvotes: 4