Skip to content

Elevating ForgeScript's capabilities, ForgeDB introduces an intuitive database solution. It seamlessly integrates with ForgeScript, offering efficient database management functions.

License

Notifications You must be signed in to change notification settings

tryforge/ForgeDB

Repository files navigation

ForgeDB logo

ForgeDB

Want to add a new advanced DataBase superpower to your ForgeScript app? Just type npm i @tryforge/forgedb

@tryforge/forge.db @tryforge/forgescript Discord

Contents

Click to see the treasure trove of magical ingredients you'd like to see!
  1. Installation
  2. Default Variables
  3. Events
  4. Updating
  5. Documentation
  6. Credits

Effortless installation


Life feels hard right? Though we can't help much, but there's this, we can provide you, making the installation of this extension easier than finding a parking space in a mall on Black Friday.

  1. Summon the npm package spirits with the following incantation in your terminal:
npm install @tryforge/forge.db sqlite3

Watch as the magical packages appear in your project!

  1. Alright, let's get this show on the road! It's time to initialize ForgeDB with Forgescript and bring your app to life.:
    const { ForgeClient } = require("@tryforge/forgescript")
    const { ForgeDB } = require("@tryforge/forge.db")
    
    /* I'm assuming that the client can be an app or anything else */
    const client = new ForgeClient({
        ...options // The options you currently have
        extensions: [
            new ForgeDB()
        ]
    })

You've done it! Your client and database are now best friends, forever connected by a magical handshake.


MongoDB Installation


Want to conquer the world of data? Well your at the right place!

  1. Ready to use up some npm magic? Cast the following spell in your terminal to summon the required packages:
npm install @tryforge/forge.db mongodb

Watch as the mystical packages materialize right before your eyes!

  1. Let's get this show on the stage! It's time to initialize your client and connect it to the magical realms of ForgeDB and MongoDB:
    const { ForgeClient } = require("@tryforge/forgescript")
    const { ForgeDB } = require("@tryforge/forge.db")
    
    // I'm assuming that the client, can be an app or anything else
    const client = new ForgeClient({
        ...options // The options you currently have
        extensions: [
            new ForgeDB({
                type: "mongodb",
                url: "Your_MongoURI_URL"
            })
        ]
    })

Your MongoDB connection is now stronger than the bond between a cat and a laser pointer.

Other Installation


Tired of the same old database blues? Ready to spice up your app's life with a new love? Follow these steps to find your bot's perfect database match:

  1. Summon the mighty ForgeDB dragon with this incantation:

    npm i @tryforge/forge.db

    Watch as the ForgeDB dragon descends from the heavens, ready to serve your app's data needs!

  2. Choose your database weapon! ForgeDB supports a variety of powerful databases. Here are the options ForgeDB supports:

    • Better Sqlite3
      npm i better-sqlite3
    • MySQL

      The classic warrior of relational databases comes in two flavours:

      • MySQL
        npm i mysql
      • MySQL2
        npm i mysql2

      Choose your flavour wisely, and your data will be in good hands!

    • Postgres
      npm i postgres
  3. Connect your database weapon to ForgeDB and ForgeScript! It's about time to forge a powerful alliance between your chosen database and the mighty ForgeDB. Follow the instructions for your specific database to complete the connection.

    Remember, a strong alliance will ensure your data is protected and your quests are successful!:

    const { ForgeClient } = require("@tryforge/forgescript")
    const { ForgeDB } = require("@tryforge/forge.db")
    
    // I'm assuming that the client, can be an app or anything else
    const client = new ForgeClient({
        ...options // The options you currently have
        extensions: [
             new ForgeDB({
                type: ""; // You've to put the DB you want to use. Available: mysql, postgres, better-sqlite3, sqlite, mongodb
                url?: string
                host?: string
                port?: number
                username?: string
                password?: string
                database?: string // The path of your DB
            })
        ]
    })

Congratulations, you've just orchestrated a cosmic connection between your client, ForgeDB, and your desired database! Your data is now safe in the hands of the intergalactic data overlords.


Android Installation


Ah, a fellow Android adventurer! You've conquered ForgeScript on your mobile device using ACode & Termux, and now you're ready to embark on a new quest. Buckle up, because we're about to connect your app to something even more magical…

  1. You have to go in the home directory run this command:
mkdir .gyp
  1. Now you have to open ACode and open Termux's home directory and make a new file named include.gypi.
  2. Now open include.gypi and paste this code:
{'variables':{'android_ndk_path': ''}}
  1. Now save the file and open Termux again.
  2. Now open the directory where you've setup your bot and run this command:
npm i @tryforge/forge.db

It is not recommended to store data on your device, using a VPS server or any other thing to host your bot is recommend.

Default variables


What's this?

Default Variables are a type of variable that are predifined in ForgeDB. These are variables in which you can set the default values of the variables manually. These are quite to what you can find in Projects Like Aoi.JS and BDFD. But there's a cstch these are optional to use.

Why should you use it?

There are many benefits of using default variables. F.e. you've got a premium guild system. When your bot joins a new guild, the default value can be set to false. So you won't have to worry about writing a spaghetti code to just set the variable when the bot joins a new guild. Well thanks to this function, it's already done for you. Do you know what, you've saved yourself from cooking a spaghetti code and saved tons of time, and made your app efficient.

What're the requirements? Can I use it in any DB setup?summary>

Well yes, you can use it in any DB setup. The requirements are simple, you just need to use ForgeDB v2.0.0 or higher.

How do you use them?

Well, they're pretty much easy-to-use, just like counting how many fingers you've got. You just head over to the main file of your client and add this:

// ForgeDB Default Variables
// You've to put this part after client initialization
ForgeDB.variables({
name: "value" 
})

Now you've made a default variable, but how do you use it? It's just as easy as herding cats, you go to your code and just do this withcraft:

/* Once again I'm assuming you've made all the setup*/
code: `
$getUserVar[name;userID;default value]
`

Events


What are DB events?

DB events are the events which get triggered when certain activities happen in your DB.

How are they helpful in developing apps powered by ForgeScript?

DB events are really helpful in developing apps powered by ForgeScript, as they help you in monitoring activity in your DB and improve your logs.

How to use them?

Now when you finish configuring your database, you will have to head over to the main file of your client and you will have to type this:

const { ForgeClient } = require("@tryforge/forgescript")
const { ForgeDB } = require("@tryforge/forge.db")
const db = new ForgeDB({
    ...options? // The options you have for ForgeDB, if any.
    events: [] /* The events you want to use. 
    Available: connect, variableCreate, variableUpdate, variableDelete */
})
const client = new ForgeClient({
    ...options // The options you currently have
   extensions: [ db ]
})
db.commands.add({
   type: "" // Available types: connect, variableCreate, variableUpdate, variableDelete
   code: `Your_Code_Goes_Here`
})

Credits

Thanks for reading till the end and using ForgeDB ;)
This package was made with love by Aggelos, an awesome man who develops cool ForgeScript extensions.

Contributor Contribution Contact
Aggelos Main Developer Discord GitHub
Aditya Descriptions for functions Discord GitHub
Aurea Made this cool ReadMe Discord GitHub
Aayush Fixed grammatical and spelling mistakes Discord GitHub
Koomball Added Android installation Discord GitHub
Econome Guide for default variables Discord GitHub

Star History

Star History Chart

About

Elevating ForgeScript's capabilities, ForgeDB introduces an intuitive database solution. It seamlessly integrates with ForgeScript, offering efficient database management functions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published