1

I am trying to get variety working with db.eval() instead of commandline --eval. This is because I get some problems with authentication.

The normal use is from the commandline:

$ mongo test --eval "var collection = 'users', maxDepth = 3" /path/to/variety.js

What I am trying to do is this:

$ mongo
>> use admin
>> db.auth("foo", "bar")
>> use anotherColl
>> db.eval("/path/to/variety.js", "var collection = 'users', maxDepth = 3")
>> Thu Mar  7 13:19:10 uncaught exception: {
    "errmsg" : "compile failed: JS Error: SyntaxError: invalid flag after regular expression nofile_a:0",
    "ok" : 0
}

Is there a way to have db.eval() eat an javascript file instead of an string?

RickyA
  • 15,465
  • 5
  • 71
  • 95

1 Answers1

1

According to @Sammaye and my gut feeling you can't put in .js files in db.eval(). However for variety there is an solution described here.

mongo -u USER-p PASS admin --eval "var collection = 'COL', db_name='DB_NAME'" variety.js

And now the authentication problem :(

Community
  • 1
  • 1
RickyA
  • 15,465
  • 5
  • 71
  • 95