# mongo-database-handler

> Local database handler

Latest version **0.0.14** (published 2023-07-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install mongo-database-handler
pnpm add mongo-database-handler
yarn add mongo-database-handler
bun add mongo-database-handler
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.14 |
| Published | 2023-07-28 |
| First published | 2023-01-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | icytea |

## Links

- npm: https://www.npmjs.com/package/mongo-database-handler
- npm.io page: https://npm.io/package/mongo-database-handler

## Dependencies (3)

- [fs](https://npm.io/package/fs.md) ^0.0.1-security
- [path](https://npm.io/package/path.md) ^0.12.7
- [mongoose](https://npm.io/package/mongoose.md) ^7.0.3

## Recent versions

- 0.0.14 (latest) — 2023-07-28
- 0.0.13 — 2023-07-26
- 0.0.12 — 2023-07-19
- 0.0.11 — 2023-07-19
- 0.0.10 — 2023-07-19
- 0.0.9 — 2023-07-19
- 0.0.8 — 2023-04-03
- 0.0.7 — 2023-02-26
- 0.0.6 — 2023-01-23
- 0.0.5 — 2023-01-23
- 0.0.4 — 2023-01-23
- 0.0.3 — 2023-01-23
- 0.0.2 — 2023-01-23
- 0.0.1 — 2023-01-23

## README

# mongo-database-handler

A simple MongoDB database handler for NodeJS. This package works with various uses, e.g. discord.js, express.js, etc. Assuming you may already know how to use MongoDB and Mongoose.

## Usage

To initiate the database handler, put this code inside your code.

Typescript:

```ts
import { DatabaseHandler } from "mongo-database-handler";
import path from "path";

// Put your Models' directory inside the init() function.
// Remember to put this inside an async function for the await to work.
await new DatabaseHandler().init(path.join(__dirname, "models"));
```

Javascript/NodeJS:

```js
const { DatabaseHandler } = require("mongo-database-handler");
const path = require("path");

// Put your Models' directory inside the init() function.
// Remember to put this inside an async function for the await to work.
await new DatabaseHandler().init(path.join(__dirname, "models"));
```

To create a model, simply look at this example.

Typescript:

```ts
import { Model } from "mongo-database-handler";

// Replace Model with whatever name you like for the model.
class Model extends Template {
	constructor() {
		super(
			{
				name: {
					type: String,
				},
				value: {
					type: String,
				},
			},
			"name"
		);
	}
}
```

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