# comfy-mongo

> Run a full-fledged MongoDB server with one line of code. No download or setup. Just, require("comfy-mongo")();

Latest version **1.1.1** (published 2020-04-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install comfy-mongo
pnpm add comfy-mongo
yarn add comfy-mongo
bun add comfy-mongo
```

Provides the commands `mongo-mac`, `mongo-win`, `comfy-mongo`, `mongo-linux`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; large bundle.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2020-04-28 |
| First published | 2019-06-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 189.6 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Instafluff |
| Maintainers | instafluff |
| Keywords | instafluff, mongo, mongodb, server, self-contained, local, database, nosql, easy, node |

## Links

- npm: https://www.npmjs.com/package/comfy-mongo
- Repository: https://github.com/instafluff/ComfyMongoDB
- Homepage: https://github.com/instafluff/ComfyMongoDB#readme
- Issues: https://github.com/instafluff/ComfyMongoDB/issues
- npm.io page: https://npm.io/package/comfy-mongo

## Dependencies (1)

- [tree-kill](https://npm.io/package/tree-kill.md) ^1.2.2

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 1.1.1 (latest) — 2020-04-28
- 1.1.0 — 2020-04-28
- 1.0.7 — 2019-06-24
- 1.0.6 — 2019-06-24
- 1.0.5 — 2019-06-18
- 1.0.4 — 2019-06-18
- 1.0.3 — 2019-06-18
- 1.0.2 — 2019-06-18
- 1.0.1 — 2019-06-18
- 1.0.0 — 2019-06-18

## README

# ComfyMongoDB
Easiest way to setup MongoDB! Run a full-fledged MongoDB server with one line of code. No download or setup. Just, `require("comfy-mongo")();`

For those of us that don't want to download and install MongoDB on the computer or for those who need a self-contained version inside a limited directory, **ComfyMongoDB** lets you start up a full MongoDB service ***SUPER EASILY*** in just one line of code.

## Instafluff ##
> *For more coding fun like this Comfy MongoDB Module, come and hang out with us at the Comfiest Corner on Twitch!*

> https://twitch.tv/instafluff

> https://twitter.com/instafluffTV

## Instructions ##
1. Install `comfy-mongo`
```
npm install comfy-mongo --save
```
2. Start MongoDB and listen for events
```javascript
var ComfyMongo = require("comfy-mongo")();
ComfyMongo.on( "ready", () => {
	console.log( "MongoDB is ready!" );
});
```
3. Connect and use MongoDB
```javascript
var ComfyMongo = require("comfy-mongo")();
ComfyMongo.on( "ready", () => {
	console.log( "MongoDB is ready!" );
	connectToMongoDB( "mongodb://localhost:27017" );
});

const MongoClient = require('mongodb').MongoClient;
function connectToMongoDB( url ) {
	MongoClient.connect( url, { useNewUrlParser: true }, ( err, client ) => {
		console.log("Connected successfully to server");
		client.close();
	});
}
```

### Running MongoDB Globally ###

If you would simply like to run an instance of MongoDB, you can install ComfyMongoDB globally and run a CLI command.

1. Install `comfy-mongo` globally
```
npm install -g comfy-mongo
```
2. Start MongoDB from console
```
comfy-mongo
```

## Connecting to MongoDB ##

The MongoDB server will start on port `27017` and can be connected to with the url: `mongodb://localhost:27017`

For an example connection, take a look at `example.js`!

## Events ##

Currently, the MongoDB events available are:

- **ready**`ComfyMongo.on( "ready", () => {} )`
    - MongoDB is ready for connections
- **output**`ComfyMongo.on( "output", ( data ) => {} )`
    - Stdout output stream
- **error**`ComfyMongo.on( "error", ( err ) => {} )`
    - Stderr output stream
- **close**`ComfyMongo.on( "close", ( code ) => {} )`
    - MongoDB has exited/closed with status code

## Supported Platforms ##

ComfyMongoDB currently works in Windows and Mac/OSX.

## MongoDB Version ##

ComfyMongoDB currently runs MongoDB Community Edition v4.0.10

## How to Specify Your Own Database Directory ##

ComfyMongoDB defaults to `./data` for storage.

To specify your own data directory, you can pass the file path in as a parameter:
```javascript
var ComfyMongo = require("comfy-mongo")( "./MyCustomDirectory" );
```

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