# mongosetup

> A promise based mongo db initialization library

Latest version **0.9.3** (published 2019-05-27) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.9.3 |
| Published | 2019-05-27 |
| First published | 2016-01-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 398.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Dejan Fajfar |
| Maintainers | dejanfajfar |
| Keywords | mongo, promises, setup, mongodb, cli, shell, tool, setup, standalone |

## Links

- npm: https://www.npmjs.com/package/mongosetup
- Repository: https://github.com/dejanfajfar/mongosetup.node
- Homepage: https://github.com/dejanfajfar/mongosetup.node#readme
- Issues: https://github.com/dejanfajfar/mongosetup.node/issues
- npm.io page: https://npm.io/package/mongosetup

## Dependencies (3)

- [chalk](https://npm.io/package/chalk.md) ^2.4.2
- [mongodb](https://npm.io/package/mongodb.md) ^3.2.6
- [check-types](https://npm.io/package/check-types.md) ^8.0.3

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

- 0.9.3 (latest) — 2019-05-27
- 0.9.2 — 2016-03-16
- 0.9.1 — 2016-03-09
- 0.5.43 — 2016-02-17
- 0.2.40 — 2016-02-14
- 0.2.36 — 2016-02-12
- 0.1.27 — 2016-02-06
- 0.1.26 — 2016-02-05
- 0.1.16 — 2016-01-21
- 0.1.7 — 2016-01-14
- 0.2.0 — 2016-01-14
- 0.0.1 — 2016-01-14

## README

[![travis ci build](https://api.travis-ci.org/dejanfajfar/mongosetup.node.svg)](https://travis-ci.org/dejanfajfar/mongosetup.node)
[![Dependencies](https://david-dm.org/dejanfajfar/mongosetup.node.svg)](https://david-dm.org/dejanfajfar/mongosetup.node)
[![npm version](https://badge.fury.io/js/mongosetup.svg)](https://badge.fury.io/js/mongosetup)


# mongosetup.node

A nodeJs module to write promises based __mongodb__ initialization/update scripts with a nice _cli_ output

![sample output](https://raw.githubusercontent.com/dejanfajfar/mongosetup.node/master/misc/output.png)

# Why?

Because __I__ believe that your application should concentrate on business logic and not how to setup and manage its data store.

Because __you__ can easily create complext DB initialization procedures that can be used on multiple instances. 

If the shiny promise based interface did not convince you then another great point in favor is the ability to run scripts __without a local mongodb installation__.

# How?

Simply install the [npm module](https://badge.fury.io/js/mongosetup) using

	$ npm install mongosetup --save

> The _--save_ will add __mongosetup__ to your project dependencies

Using the fluent interface we can create easy to __read__ and __maintain__ initialization and update scripts.

	var mongoSetup = require('mongosetup');
	var cp = mongoSetup.collectionPromises;
	
	var connectionData = {
		connectionString : "mongodb://localhost:27017/demo"
	};
	mongoSetup.connectTo(connectionData)
		.then(cp.requireVersion("1.0.0-cp1"))
		.then(cp.useCollection("MyCollection"))
		.then(cp.deleteAllDocuments())
		.then(cp.insertOne({name : "Domonique Branson"}))
		.then(cp.insertMany([{name : "Wonda	Babcock"}, {name : "Ambrose	Tyree"}, {name : "Daysi	Oden"}]))
		.then(cp.createIndex({name : 1}, {name : "name_index"}))
		.then(cp.updateVersion("1.0.0-cp2"))
		.then(cp.disconnect())
		.catch(mongoSetup.handleError());

# Where to next?

__What a quick scoop of the most common usage scenarios?__ Have a look at [our samples here](https://github.com/dejanfajfar/mongosetup.node/tree/master/examples)

__Need more information?__ Refer to [our wiki](https://github.com/dejanfajfar/mongosetup.node/wiki)

__Found something lacking?__ Write a bug to [our bug tracker](https://github.com/dejanfajfar/mongosetup.node/issues)

---

npm badge provided by [http://badge.fury.io/](http://badge.fury.io/)

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