🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@aoitelegram/database

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aoitelegram/database

A custom database designed specifically for aoitelegram

latest
npmnpm
Version
1.1.1
Version published
Maintainers
1
Created
Source

@aoitelegram/database

NPM Version Bot API NPM Downloads License

@aoitelegram/database is a Node.js library for managing various types of databases, including Firebase Realtime Database, MongoDB, and a generic file-based storage solution. It provides a unified interface for performing CRUD operations, managing events, and checking database responsiveness.

Installation

You can install the library via npm:

npm install @aoitelegram/database

Usage

AoiTelegram Connect

// CommonJS
const { AoiClient } = require("aoitelegram");
const { AoiDB } = require("@aoitelegram/database");
// Esm/TypeScript
import { AoiClient } from "aoitelegram";
import { AoiDB } from "@aoitelegram/database";

const database = new AoiDB({
  type: "storage",
  logger: true,
  options: {
    tables: ["main"],
  },
});

const bot = AoiClient("token", {
  extension: [database],
  // ...other
});

database.timeoutCommand({
  id: "other",
  code: "$print[Yesssss!;$timeoutData[key]]",
});

bot.addCommand({
  command: "start_timeout",
  code: "$setTimeout[other;10m;{ key: 'Hello World' }]",
});

// Set user variables in a table.
database.variables(
  {
    sempai: 10,
    string: "Hello, world!",
    aoijs: true,
    webapp: false,
    mz: [],
  },
  "main",
);

bot.connect();

FirebaseDB

import { FirebaseDB } from "@aoitelegram/database";

// Create a FirebaseDB instance
const db = new FirebaseDB("<your-firebase-database-url>", {
  projectId: "<your-firebase-priject-id>",
  tables: ["users", "posts"], // Optional: specify tables
});

// Connect to the Firebase database
await db.connect();

// Perform operations such as get, set, delete, etc.
await db.set("users", "user1", { name: "John", age: 30 });
const user = await db.get("users", "user1");
console.log(user); // Output: { name: 'John', age: 30 }

MongoDB

import { MongoDB } from "@aoitelegram/database";

// Create a MongoDB instance
const db = new MongoDB("<your-mongodb-url>", {
  tables: ["users", "posts"], // Specify tables
});

// Connect to the MongoDB database
await db.connect();

// Perform operations such as get, set, delete, etc.
await db.set("users", "user1", { name: "John", age: 30 });
const user = await db.get("users", "user1");
console.log(user); // Output: { name: 'John', age: 30 }

MySqlDB

import { MySqlDB } from "@aoitelegram/database";

// Create a MongoDB instance
const db = new MySqlDB(<url> and <connection options> (host, user, password, port),
  ["users", "posts"], // Specify tables
);

// Connect to the MongoDB database
await db.connect();

// Perform operations such as get, set, delete, etc.
await db.set("users", "user1", { name: "John", age: 30 });
const user = await db.get("users", "user1");
console.log(user); // Output: { name: 'John', age: 30 }

StorageDB

import { StorageDB } from "@aoitelegram/database";

// Create a StorageDB instance
const db = new StorageDB({
  path: "./data", // Optional: specify data directory
  tables: ["users", "posts"], // Optional: specify tables
});

// Connect to the storage database
await db.connect();

// Perform operations such as get, set, delete, etc.
await db.set("users", "user1", { name: "John", age: 30 });
const user = await db.get("users", "user1");
console.log(user); // Output: { name: 'John', age: 30 }

API Documentation

Please refer to the API Documentation for detailed information on classes, methods, and usage examples.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please create a GitHub issue or submit a pull request. Additionally, feel free to reach out to me on Telegram via my group AoiTelegram or on Discord using my username sempaika_chess.

License

This library is released under the MIT License.

Keywords

javascript

FAQs

Package last updated on 21 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts