Skip to content

NanotechPikachu/aoi.mongodb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aoi.MongoDB

A Mongo DB connecting package for AoiJS without conflicting with AoiDB!


Installation

npm install github:NanotechPikachu/aoi.mongodb

Index Setup

const aoimongo = require("aoi.mongodb");
const { AoiClient } = require("aoi.js");

// AOI setup
const client = new AoiClient({
    token: "DISCORD BOT TOKEN",
    prefix: "DISCORD BOT PREFIX",
    intents: ["MessageContent", "Guilds", "GuildMessages"],
    events: ["onMessage", "onInteractionCreate"],
    database: {
        type: "aoi.db",
        db: require("@akarui/aoi.db"),
        dbType: "KeyValue",
        tables: ["main"],
        securityKey: "a-32-characters-long-string-here"
    }
});

client.loadCommands("./commands/", true);

// aoi.MongoDB setup
aoimongo.setup({
    client: client,
    mongoURL: "MONGO URL", // Like - "mongodb+srv://..."
    variables: require("Path to Variable File") // You MUST initialize a file with variables and require() it here. Like - require("./var.js") if var.js is the variables file name
});

Variables File

module.exports = {
    num: 0, // Number
    ar: [], // Array
    ob: {}, // Object
    st: "Hola!", // String
    boo: true // Boolean
}

Warning

Without the variables file, you cannot use functions nor the app(bot) will work.

Note

It is also essential to make(initialize) the variable in this file before accessing it; the same as AoiDB. Provided, it must not be the same file AKA this file and the AoiDB variables file are different.

Functions

aoi.MongoDB AoiDB Usage
$getMVar $getVar $getMVar[varname]
$getGlobalUserMVar $getGlobalUserVar $getGlobalUserMVar[varname;userId?]
$getGuildMVar $getGuildVar $getGuildMVar[varname;guildId?]
$getMessageMVar $getMessageVar $getMessageMVar[varname;messageId?]
$getUserMVar $getUserVar $getUserMVar[varname;userId?;guildId?]
$getChannelMVar $getChannelVar $getChannelMVar[varname;channelId?]
$setMVar $setVar $setMVar[varname;value]
$setGlobalUserMVar $setGlobalUserVar $setGlobalUserMVar[varname;value;userId?]
$setGuildMVar $setGuildVar $setGuildMVar[varname;value;guildId?]
$setMessageMVar $setMessageVar $setMessageMVar[varname;value;messageId?]
$setUserMVar $setUserVar $setUserMVar[varname;value;userId?;guildId?]
$setChannelMVar $setChannelVar $setChannelMVar[varname;value;channelId?]

Add-on Functions

$mongoArray

A function for performing Array functions "push" and "pull".

Syntax: $mongoArray[varname;value;action;varType;id?]

  • Action - push / pull

  • varType - user / globaluser / guild / global / message / channel

  • id - default null(or depending on varType default will be auto added). If you want to use vars which has 2 params like user(which supports guildId and userId) use like - if "user" -> userId:guildId

Note

Basically, the difference is that you have to add an "M" before the "Var" in the function name and Walah! you can use AoiDB as well as, Mongo DB in your app!

About

A mongo DB connecting package for AoiJS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published