I would like to make query MongoDB for documents based on a regex expression that I contruct. For e.g I have constructed a simple regex as follows that is a combination of a
You need to create a regular expression object from the string using the RegExp constructor as the /.../ syntax is only for use with literals.
RegExp
/.../
var stream = collection.find({"FirstName": new RegExp(val)}).stream();