I'm trying to do the following. I want to pass in an email address on the command line using --eval:
mongo --eval "var [email protected]" userfind.js
Where userfind.js:
use dev;
db.users.find({email:"emailparam"}).pretty();
Getting the following error:
$ mongo --eval "var [email protected]" userfind.js
MongoDB shell version: 3.2.4
connecting to: test
2016-08-12T07:02:27.033-0700 E QUERY [thread1] SyntaxError: illegal character @(shell eval):1:25
**from the output above, I'm not also able to switch to my database dev using use dev.
I've tried escaping as well and no luck:
$ mongo --eval "var emailparam=foo.bar\@yahoo.com" userfind.js
Is there a way to do this?