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

An advanced DataBase extension for ForgeScript powered apps.

@tryforge/forge.db @tryforge/forgescript Discord

Contents

  1. Installation
  2. Events
  3. Updating
  4. Documentation
  5. Credits

Effortless installation


  1. Run the following command to install the required npm packages:
npm i @tryforge/forge.db sqlite3
  1. Now, in your client initialization:
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()
    ]
})

Congratulations, you have successfully connected your client to a local database.

MongoDB Installation


  1. Run the following command to install the required npm packages
npm i @tryforge/forge.db mongodb
  1. Now, in your client initialization:
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"
        })
    ]
})

Congratulations, you have successfully connected your client to a MongoDB database

Other Installation


Your here because you want to try other DBs. So now just follow the steps below to set up your bot to work with other DBs:

  1. You have to first install ForgeDB, so you just run this command in your terminal:
npm i @tryforge/forge.db
  1. Now that you've installed ForgeDB, you'll now have to install the DB package you want to use. Here are the ones ForgeDB currently supports:
    • Better Sqlite3
    npm i better-sqlite3
    • MySQL

      MySQL have got two versions, you can use either of them.

      • MySQL
        npm i mysql
      • MySQL2
        npm i mysql2
    • Postgres
    npm i postgres
  2. Now that you have installed your preferred DB package, now you have to connect it with ForgeDB and 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
        })
    ]
})

Congratulations, you have now successfully connected your DB with ForgeDB and your client is connected to it now.

Events


  • What are DB events?

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

  • How are they helpful in developing apps powered by ForgeScript?

DB events are really helpful in developing apps owned 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 main file of your client and you will have to type this:

const { ForgeDB } = require("@tryforge/forge.db")

const db = new ForgeDB({
    ...options? //The options you have for ForgeDB if you have 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 by with love aggelos, an awesome man who develops cool ForgeScript extensions.

Contributor Contribution Conatct
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 Improved Readme file Discord GitHub

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

Contributors 9