0.1.1 • Published 11 years ago

mongooser v0.1.1

Weekly downloads
35
License
-
Repository
github
Last release
11 years ago

#Mongooser

Mongoose REPL

install

npm install mongooser -g

usage

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:

exports.connect = 'mongodb://localhost:port/dbname'
exports.Users = 'path/to/your/schema'
exports.Views = 'path/to/your/model'
exports.Checkings = [ schema, options ]

connection string (required)

// key must be named "connect"
exports.connect = 'mongodb://localhost/name_of_db'

Schemas/Models

There are three approaches to expose your models to the REPL:

exports.NameOfYourModel = 'path/to/your/schema'

// or

exports.NameOfYourModel = 'path/to/your/model'

// or

exports.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.

repl

When mongooser starts it exposes your Models globally:

npm.io

You can query in traditional Mongoose fashion:

mongooser> Book.where('title').equals('How to make paper airplanes').exec(print)
mongooser> ...
mongooser> null { title: 'A Tale of Two Cities', _id: 4fbb25a950badf0000000001 }

A few observations:

  • print: is a global function available which prints query results to the repl nicely.
  • p: is an alias of print
  • executing a query dumps the query object to the repl first (represented above with ...)
  • the print helper displays returned arguments in order

globals

  • connection: your db connection object
  • models: array of each loaded Model name
  • schemas: your schemas included in configuration
  • mongoose: the mongoose module
  • Models: each model created from your configuration

tests

Run the tests with make test.

LICENSE

0.1.1

11 years ago

0.1.0

11 years ago

0.0.6

12 years ago

0.0.5

12 years ago

0.0.4

12 years ago

0.0.3

12 years ago

0.0.2

12 years ago