@onurege3467/zerohelper
Version:
ZeroHelper is a versatile JavaScript library offering helper functions and database utilities for developers. It supports MongoDB, MySQL, SQLite, Redis, and PostgreSQL.
37 lines (32 loc) • 890 B
JavaScript
const mongodb = require("mongodb");
const { Database } = require("../structers/Database.js");
class Client {
/**
* @type {mongodb.MongoClient}
*/
Client;
/**
* @param {MongoClient} client
*/
constructor(client) {
this.Client = client;
}
/**
* If database does not exists, creates database then returns the database. Otherwise just returns database.
* @param {String} databaseName
* @return {Database}
*/
database(databaseName) {
const database = new Database(this.Client, databaseName);
return database;
}
/**
* Drops the database.
* @param {String} databaseName
* @return {Promise<void>}
*/
async dropDatabase(databaseName) {
await this.Client.db(databaseName).dropDatabase();
}
}
module.exports = { Client };