npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aoi.mongodb

v1.2.2

Published

aoi.mongodb - Allows storing of vars to mongoDB without conflicting with aoiDB!

Downloads

32

Readme

aoi.MongoDB

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

Table Of Contents

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

$mongoPing

A function which returns the latency of mongo DB in ms.

Syntax: $mongoPing

$deleteUserVar

This function works primarily like a reset function which will erase the data from MongoDB.

Syntax: $deleteUserVar[varname;userId?;guildId?;returnCount?]

  • userId - The User ID whose var should be reset. You can also pass "all" to reset all users var in a specific guild. (Default - Author ID)

  • guildId - ID of the guild where user is in to reset. (Default - User's Guild ID)

  • returnCount - If you wish to return the number of users var that it has reset, enable it by passing "true". Only when passing "all" in userId will it return a number more than 1. Normally, it returns 1 or 0 (if there is no data of that particular user in Mongo DB). (Default - false)

$deleteGuildVar

This function works primarily like a reset function which will erase the data from MongoDB.

Syntax: $deleteGuildVar[varname;guildId?;returnCount?]

  • guildId - ID of the guild to reset. You can also pass "all" to reset all users var in a specific guild. (Default - The current Guild ID)

  • returnCount - If you wish to return the number of guilds var that it has reset, enable it by passing "true". Only when passing "all" in guildId will it return a number more than 1. Normally, it returns 1 or 0 (if there is no data of that particular guild in Mongo DB). (Default - false)

$deleteMessageVar

This function works primarily like a reset function which will erase the data from MongoDB.

Syntax: $deleteMessageVar[varname;messageId?;returnCount?]

  • messageId - ID of the message to reset. You can also pass "all" to reset all messages var. (Default - The current Message ID)

  • returnCount - If you wish to return the number of messages var that it has reset, enable it by passing "true". Only when passing "all" in messageId will it return a number more than 1. Normally, it returns 1 or 0 (if there is no data of that particular guild in Mongo DB). (Default - false)

$deleteChannelVar

This function works primarily like a reset function which will erase the data from MongoDB.

Syntax: $deleteChannelVar[varname;channelId?;returnCount?]

  • channelId - ID of the channel to reset. You can also pass "all" to reset all channels var. (Default - The current Channel ID)

  • returnCount - If you wish to return the number of channels var that it has reset, enable it by passing "true". Only when passing "all" in channelId will it return a number more than 1. Normally, it returns 1 or 0 (if there is no data of that particular guild in Mongo DB). (Default - false)

$deleteGlobalUserVar

This function works primarily like a reset function which will erase the data from MongoDB.

Syntax: $deleteGlobalUserVar[varname;userId?;returnCount?]

  • userId - ID of the user to reset. You can also pass "all" to reset all users var. (Default - The current Message ID)

  • returnCount - If you wish to return the number of users var that it has reset, enable it by passing "true". Only when passing "all" in userId will it return a number more than 1. Normally, it returns 1 or 0 (if there is no data of that particular guild in Mongo DB). (Default - false)

[!NOTE] Basically, the difference is that you have to add an "M" before the "Var" in the function name(AOI-Based) and Walah! you can use AoiDB as well as, Mongo DB in your app!

DiscordJS Usage

This package also has JavaScript functions which can be used with $djsEval which you are evaling DJS / JS in aoi or not.

[!NOTE] This section can only be used in JS evaling. But, can be used with non aoi packages too!

Functions

  • getUserVar()
  • getGlobalUserVar()
  • getGuildVar()
  • getChannelVar()
  • getMessageVar()
  • getGlobalVar()
  • setUserVar()
  • setGlobalUserVar()
  • setGuildVar()
  • setChannelVar()
  • setMessageVar()
  • setGlobalVar()

In order to use the above function, import it in the JS medium like:

const { functionName } = require('aoi.mongodb/func'); // 'func' is the path where these functions are made