Is there any way to find a document in MongoDB collection, which field is a substring to my "string"?
Just a little example. Suppose I have this collection:
{"str": "pho", ...},
{"str": "sma", ...},
{"str": "goa", ...},
{"str": "aba", ...},
{"str": "gag", ...}
...
And my "string" is "smartphone" for example. So the result of the query should be:
{"str": "pho", ...}
{"str": "sma", ...}
For now I use this regex to solve my problem:
^[smartphone]+$
That works, but it'll also match documents like {"str": "ophms", ...}
which "str" is not a substring of "smartphone".
I know, my question is exact like a #2123738, but that's about sql databases, which querying methods differents a lot.