# mongooser

> Mongoose REPL

Latest version **0.1.1** (published 2013-04-16) · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install mongooser
pnpm add mongooser
yarn add mongooser
bun add mongooser
```

Provides the command `mongooser`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2013-04-16 |
| First published | 2012-05-22 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.4.2 |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+11 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 23 |
| Author | Aaron Heckmann |
| Maintainers | aaron |

## Links

- npm: https://www.npmjs.com/package/mongooser
- Repository: https://github.com/aheckmann/mongooser
- npm.io page: https://npm.io/package/mongooser

## Dependencies (3)

- [debug](https://npm.io/package/debug.md) 0.7.0
- [mongoose](https://npm.io/package/mongoose.md) 3.6.x
- [commander](https://npm.io/package/commander.md) 0.6.1

## Recent versions

- 0.1.1 (latest) — 2013-04-16
- 0.1.0 — 2013-03-20
- 0.0.6 — 2012-11-14
- 0.0.5 — 2012-11-14
- 0.0.4 — 2012-07-27
- 0.0.3 — 2012-06-28
- 0.0.2 — 2012-05-22

## README

#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:

```js
exports.connect = 'mongodb://localhost:port/dbname'
exports.Users = 'path/to/a/schema'
exports.Views = 'path/to/a/model'
exports.Checkins = [ 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](https://github.com/aheckmann/mongooser/blob/master/test/test.js) for another example.

## repl

When `mongooser` starts it exposes your `Models` globally:

![](http://dl.dropbox.com/u/11198966/mongooser-startup.png)

You can query in traditional `Mongoose` fashion:

![](http://dl.dropbox.com/u/11198966/mongooser-query.png)

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
  - the `print` helper displays returned arguments in order
  - `print` mimics nodejs repl behavior by assigning the 2nd argument passed to the global `_`.
  - all queries, as with normal mongoose applications, are run asynchronously

## globals

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

## tests

Run the tests with `make test`.

[LICENSE](https://github.com/aheckmann/mongooser/blob/master/LICENSE)

---
_Source: https://npm.io/package/mongooser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
