The models.require method that loads models does not return the model directly, but instead returns a function that can be used to fetch the model. This is so that when two models make use of each other, the models are allowed time to set themselves up. That is why models are loaded as models.require(...)(). This returned function has a number of properties on it that can be used as well.

The mongoose schema object. This can be accessed immediately without waiting for the model to be created if you need access sooner. This could be used as an alternative to the $circular syntax described above.

The REPL is a simple JavaScript interpreter with access to your mongoose-models. Before using the REPL, it will need to be loaded and configured.

$ cp ./node_modules/mongoose-models/bin/repl.js ./repl.js

Now, open up repl.js and change the values in conf to match your configuration settings. You can start the REPL by running:

$ node repl.js

The REPL comes with some helpful features on top of the standard node REPL. First, mongoose-models is already loaded for you and is available as models. Second, models.require has been patched to automatically store loaded models in global. There are also some useful functions defined.