Given that I have a string such as
"Donald Trump <donald@trump.com>"
"Art Job <art@job.com>"
How can I find every row that contains "donald@trump.com" using MongoDB in Rails?
Thanks
See Question&Answers more detail:osGiven that I have a string such as
"Donald Trump <donald@trump.com>"
"Art Job <art@job.com>"
How can I find every row that contains "donald@trump.com" using MongoDB in Rails?
Thanks
See Question&Answers more detail:osFrom the documentation:
search_string = params['search']
# Constructor syntax coll.find({"name" => Regexp.new(search_string)})
# Literal syntax coll.find({"name" => /#{search_string}/})
Beware though... You can't use an index with this query since your regex isn't anchored to the front of the string.