@tryforge/forge.db
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

ForgeDB

An advanced DataBase extension for ForgeScript.

@tryforge/forge.db @tryforge/forgescript Discord

Table of Contents

  1. Installation
  2. How to use Events
  3. How to update
  4. Documentation
  5. Credits

Quick Installation

Download these npm packages:

npm i @tryforge/forge.db sqlite3

Now, in your client initialization:

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

// I'll assume client, can be bot or anything else
const client = new ForgeClient({
    ...options // The options you currently have
    extensions: [
        new ForgeDB()
    ]
})

And voi-la, you bot now has been connected a local database.

MongoDB Installation

Download these npm packages:

npm i @tryforge/forge.db mongodb

Now, in your client initialization:

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

// I'll assume client, can be bot or anything else
const client = new ForgeClient({
    ...options // The options you currently have
    extensions: [
        new ForgeDB({
            type: "mongodb",
            url: "Your_MongoURI_URL"
        })
    ]
})

And voi-la, you bot now has been connected a mongo database.

Other DB Installation

If you want to install other dbs you need to follow these steps:

  1. Install forge.db package
npm i @tryforge/forge.db
  1. Install your db package
    • For better-sqlite3
    npm i better-sqlite3
    • For mysql
    npm i mysql # or npm i mysql2
    • For postgres
    npm i postgres
  2. Connect ForgeDB with ForgeScript
const { ForgeDB } = require("@tryforge/forge.db")

// I'll assume client, can be bot or anything else
const client = new ForgeClient({
    ...options // The options you currently have
    extensions: [
        new ForgeDB({
            type: "mysql" | "postgres" | "better-sqlite3";
            url?: string
            host?: string
            port?: number
            username?: string
            password?: string
            database?: string //the path of your db
        })
    ]
})

And voi-la, you bot now has been connected a database.

How to use Events

Once you configure your database you will head over to the main file of your bot and you will 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.
    //Availalbe: `connect`, `variableCreate`, variableUpdate, `variableDelete`
}) 

const client = new ForgeClient({
    ...options // The options you currently have
    extensions: [ db ]
})

db.commands.add({
    type: "connect" | "variableCreate" | "variableUpdate" | "variableDelete"
    code: `Your_Code_Goes_Here`
})

And voi-la, you learnt how to use database events!

Credits

Thanks for reading this guide and for using ForgeDB
This package was made by with love aggelos, a developer of ForgeScript. Use ForgeScript, it's better and easier.

Also huge thanks to aditya and aurea for their contributions <3

Package Sidebar

Install

npm i @tryforge/forge.db

Weekly Downloads

28

Version

2.0.0

License

MIT

Unpacked Size

306 kB

Total Files

265

Last publish

Collaborators

  • yuzudaneko
  • berk404
  • aggelos_007