Search code examples
mongodbmongodb-shell

Can not add function to mongodb


I don't know when the problem begin. I find that when i create a new function to mongodb, and then run it like this:
db.loadServerScripts(); testFun('xxx');
Two errors will occur:
SyntaxError: missing } after property list src/mongo/shell/db.js:1038 ReferenceError: testFun is not defined (shell):1 But the old functions work fine. And when I delete one old function, and recreate it without anything changed, it also results in the same error above.

The version of mongodb I used is 2.6.10.


Solution

  • I think I have found the answer to this question. The error was cased by some other function. The error message puzzled me , I used to think that it must be an error from the mongo itself. I delete some mongo function written by me, and then the error was missing. Now I can run testFun successfully.