npm install mongooser -g
mongooser [options]Options:-h, --help output usage information-V, --version output the version number-c --config <path> configuration path
Your configuration should be a module. The module should be formatted as follows:
exportsconnect = 'mongodb://localhost:port/dbname'exportsUsers = 'path/to/a/schema'exportsViews = 'path/to/a/model'exportsCheckins = schema options
// key must be named "connect"exports.connect = 'mongodb://localhost/name_of_db'
There are three approaches to expose your models to the REPL:
exports.NameOfYourModel = 'path/to/your/schema'// orexports.NameOfYourModel = 'path/to/your/model'// orexports.NameOfYourModel = [ new Schema(..), schemaOptions ]
The array approach allows us to quickly set up configuration by including the
Schema and its options directly in the configuration file.
See the test configuration for another example.
mongooser starts it exposes your
You can query in traditional
A few observations:
p: is an alias of
- executing a query dumps the query object to the repl first
- all queries, as with normal mongoose applications, are run asynchronously
connection: your db connection object
models: array of each loaded Model name
schemas: your schemas included in configuration
ObjectIdthe ObjectId constructor
- Models: each model created from your configuration
Run the tests with