UNPKG

@sigiljs-community/mongo-plugin

Version:

Plugin for SigilJS framework that provides MongoDB interactions

26 lines (25 loc) 679 B
import { SigilPlugin as i } from "@sigiljs/sigil"; import { MongoClient as o } from "mongodb"; import t from "./mongo-controller.mjs"; class g extends i { static name = "MongoPlugin"; #n; constructor() { super(), this.#n = new o(this.$pluginConfig.connectUri, this.$pluginConfig.clientOptions); } async onInitialize() { await this.#n.connect(); } /** * Create new instance of the MongoDB controller for specific database * * @param {string} databaseName name of the database * @returns {MongoController} instance of the MongoDB controller */ createController(n) { return new t(this.#n, n, this.logger); } } export { g as default };