0.0.14 • Published 10 months ago

mongo-database-handler v0.0.14

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months 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

10 months ago

0.0.11

10 months ago

0.0.12

10 months ago

0.0.13

10 months ago

0.0.14

10 months ago

0.0.9

10 months ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago