# basic-mongo-wrapper

> Simple mongodb interface to speed up communication with db

Latest version **1.0.1** (published 2021-03-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install basic-mongo-wrapper
pnpm add basic-mongo-wrapper
yarn add basic-mongo-wrapper
bun add basic-mongo-wrapper
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-03-13 |
| First published | 2021-03-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 13.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | WilyFoxM |
| Maintainers | wilyfoxm |
| Keywords | Mongo, Mongodb, Database |

## Links

- npm: https://www.npmjs.com/package/basic-mongo-wrapper
- Repository: https://github.com/WilyFoxM/basic-mongo
- Homepage: https://github.com/WilyFoxM/basic-mongo#readme
- Issues: https://github.com/WilyFoxM/basic-mongo/issues
- npm.io page: https://npm.io/package/basic-mongo-wrapper

## Dependencies (1)

- [mongodb](https://npm.io/package/mongodb.md) ^3.6.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

- 1.0.1 (latest) — 2021-03-13
- 1.0.0 — 2021-03-13

## README

# Installation

### First install mongodb driver:

`npm i mongodb`

### Then install wrapper:

`npm i basic-mongo`

# Using

#### This package is promise based. It means you must use `await` or `.then` to get results

## Starting

#### Declare package

```JS
const Interface = require("basic-mongo");
```

#### Creating instance of

```JS
let database = new Interface(url, dbname);
```

##### Where url: connection string, dbname: database name

#### Getting information from database

```JS
const Interface = require("basic-mongo");
let database = new Interface(url, dbname);

await database.findOne("users", { name: 'Fox', status: 'Premium' }).then((data) => {
  console.log(data);
  return;
});
```

# Functions

##### Find - return promise with array of all results

```JS
database.find(collectionname, params);
```

##### findOne - return promise with object

```JS
database.findOne(collectionname, params);
```

##### findOneAndUpdate - return promise with updated object

```JS
database.findOneAndUpdate(collectionname, paramsfind, paramsupdate);
```

##### updateOne - return promise with updated object

```JS
database.updateOne(collectionname, paramsfind, paramsupdate);
```

##### updateMany - return promise with all updated objects

```JS
database.updateMany(collectionname, paramsfind, paramsupdate);
```

##### insertOne - return promise with inserted object

```JS
database.insertOne(collectionname, data);
```

##### insertMany - return promise with all inserted objects

```JS
database.insertMany(collectionname, dataArray);
```

##### deleteOne - return promise with deleted object

```JS
database.deleteOne(collectionname, paramsfind);
```

##### deleteMany - return promise with all deleted objects

```JS
database.deleteMany(collectionname, paramsfind);
```

##### drop - delete all data in collection

```JS
database.drop(collectionname);
```

##### createCollection - create collection in database

```JS
database.createCollection(collectionname, data);
```

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