0.0.14 • Published 2 years ago

mongo-database-handler v0.0.14

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

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:

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:

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:

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"
		);
	}
}
0.0.10

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.14

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago