There are a couple of examples of how to create "stored procedures" in MongoDB (here is one) but they only show how to add the code directly, for example in the mongo shell. For any nontrivial stored procedure one would want to store the code in a .js file and 'import' the file into MongoDB. That way it can be easily edited, versioned, etc.
Is there a way to do this?