Note: use of $where is generally discouraged as JavaScript evaluation cannot take advantage of indexes. If you can include an example of a sample document and actual query you're trying to construct, there is likely a more performant alternative to recommend.
@stennie I'm not sure there is. {$where: "myVariable.match(new RegExp(this.test + '$'))"}. If myVariable = 'something', it should get documents that match the end substring, e.g., mething, thing, ing.
$whereis generally discouraged as JavaScript evaluation cannot take advantage of indexes. If you can include an example of a sample document and actual query you're trying to construct, there is likely a more performant alternative to recommend.{$where: "myVariable.match(new RegExp(this.test + '$'))"}. IfmyVariable = 'something', it should get documents that match the end substring, e.g.,mething,thing,ing.$regex