Dubnium
v2
v2
  • Install
  • Overview
  • Initialize
  • Manage
  • Get
  • Modify
  • Templates
  • CLI
  • Events
  • Plugins
    • Create
  • Miscellaneous
  • Update Log
  • Need more help?
Powered by GitBook
On this page
  • 1. Create a file with the plugins you wish to use
  • 2. Load the file
  • 3. Use the Plugin
  • Customize Plugin's access

Was this helpful?

Plugins

PreviousEventsNextCreate

Last updated 2 years ago

Was this helpful?

Make sure you trust the plugin as they have access to your database. Read on a way around this.

1. Create a file with the plugins you wish to use

my_plugins.js
module.exports = {
    package_example: require("dubnium-test-pkg"),
    function_example: () => { console.log("Hello, world") },
}

2. Load the file

You must run the loadFromFile() method before the plugin can be used.

update_plugins.js
const { PluginManager } = require("dubnium")
PluginManager.loadFromFile('./path/to/my_plugins.js')

Be sure to run this! You can check if the plugin is registered by checking PluginManager.activePlugins. If you updated Dubnium, the plugins may have been reset.

3. Use the Plugin

Allow access to all data

index.js
const { Dubnium } = require("dubnium")
const db = new Dubnium('./test_db','json')
db.usePlugin("name")

Customize Plugin's access

If you do not want to give access to your data through Dubnium, you can also access the plugins property.

index.js
const { Dubnium } = require("dubnium")
const db = new Dubnium('./test_db','json')
db.plugins.name(database, record)

Plugins may ask for database & record (calling the usePlugin method automatically passes them both, if possible). You can set either to null if you do not wish to give access.

below