# mongodb-promise

> A mongodb-native promise library

Latest version **0.0.4** (published 2014-04-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install mongodb-promise
pnpm add mongodb-promise
yarn add mongodb-promise
bun add mongodb-promise
```

## 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.0.4 |
| Published | 2014-04-28 |
| First published | 2014-04-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Jeremy Bowles |
| Maintainers | jbong |
| Keywords | mongo, mongodb, promise, promises, promises-a, promises-aplus, node |

## Links

- npm: https://www.npmjs.com/package/mongodb-promise
- Repository: https://github.com/jbong/mongodb-promise
- Issues: https://github.com/jbong/mongodb-promise/issues
- npm.io page: https://npm.io/package/mongodb-promise

## Dependencies (2)

- [q](https://npm.io/package/q.md) ~1.0.1
- [mongodb](https://npm.io/package/mongodb.md) ~1.4.0

## 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.0.4 (latest) — 2014-04-28
- 0.0.3 — 2014-04-25
- 0.0.2 — 2014-04-23
- 0.0.1 — 2014-04-23

## README

mongodb-promise
---------------

[![Build Status](https://travis-ci.org/jbong/mongodb-promise.svg?branch=master)](https://travis-ci.org/jbong/mongodb-promise)

Mongodb-promise is a light promise wrapper around [node-mongodb-native](https://github.com/mongodb/node-mongodb-native).


## Quick Examples

```js
var mp = require('mongodb-promise');

// Obtaining a connection
mp.MongoClient.connect("mongodb://127.0.0.1:27017/test").then(function(db){
    db.close().then(console.log('success'));
}, function(err) {
    console.log(err);
});

// Read Db stats
mp.MongoClient.connect("mongodb://127.0.0.1:27017/test")
.then(function(db){
    return db.stats().then(function(stats) {
        console.log(stats);
        db.close().then(console.log('success'));
    })
})
.fail(function(err) {console.log(err)});

// Insert documents
mp.MongoClient.connect("mongodb://127.0.0.1:27017/test")
    .then(function(db){
        return db.collection('test')
            .then(function(col) {
                return col.insert([{a : 1}, {a : 2}])
                    .then(function(result) {
                        console.log(result);
                        db.close().then(console.log('success'));
                    })
            })
})
.fail(function(err) {console.log(err);});

// Read all documents
mp.MongoClient.connect("mongodb://127.0.0.1:27017/test")
    .then(function(db){
            return db.collection('test')
                .then(function(col) {
                    return col.find({a : 1}).toArray()
                        .then(function(items) {
                            console.log(items);
                            db.close().then(console.log('success'));
                        })
            })
})
.fail(function(err) {console.log(err)});

// Read each document
mp.MongoClient.connect("mongodb://127.0.0.1:27017/test")
    .then(function(db){
        return db.collection('test')
            .then(function(col) {
                return col.find({a : 1}).each(function(doc) {
                    console.log(doc);
                })
                .then(function() {
                    db.close().then(console.log('success'));
                })
        })
})
.fail(function(err) {console.log(err);});

```
## Download

    npm install mongodb-promise

## Test

    make test

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