Use Telegram channel as a minimal database.

Overview

It's a work in progress!

The TGDB

Use Telegram channel as a minimal databases! ๐Ÿš€ It's fast, faster than I expected it to be, and like Telegram, it's free, unlimited and ๐Ÿ”“ secure, because you know, it is using Telegram's storage ๐Ÿ˜ฌ . You may want to look at "Why this might not be a good idea/choice?" also.

What is this?

With this library, you can use your private or public Telegram channel as minimal databases for your projects. Create multiple databases, add, edit and delete records. It's still a small concept and pretty bad code.

Installation

Install the package using NPM via GitHub:

npm install dcdunkan/tgdb#main

Usage

Here's a minimal example on how to use this library. But, initialize the TGDB instance follow these steps first:

  1. Create a private or public Telegram channel.
    • Send a message to the channel with the text: "tgdb:entry".
    • Get the channel chat_id and message_id of that message you just sent.

You may use @jsoonbot, @ForwardInfoBot or bots like that to get the chat_id and message_id, by forwarding that message you just sent in the channel.

  1. Go to https://my.telegram.org/ and login with your account.
    • Get the API ID and API Hash.
    • Get string session by running this installation example of GramJS and save it somewhere.

Installation example: https://painor.gitbook.io/gramjs/#installation

Create a TGDB instance

import { TGDB } from "tgdb-core";

const tgdb = new TGDB({
  apiId: 123456, // API ID from https://my.telegram.org/
  apiHash: "ABCD", // API hash from https://my.telegram.org/
  stringSession: "...", // String session you got from GramJS
  channelId: -100071801131325, // Channel `chat_id`
  entryPoint: 4, // `message_id` of the message "tgdb:entry"
});

await tgdb.connect(); // connect to the database

Work with the database

// Create a database
const db = await tgdb.createDatabase("employees");
// Or you could use
const db = await tgdb.database("employees");
// ^ it chooses an existing database, OR
// creates one if it does not exists.

// Insert record to the database
await db.insert("12345678", { first_name: "Linus" });

// Get the record data using
const data = await db.get("12345678");

// Modify the existing record data
await db.modify("12345678", {
  ...data,
  second_name: "Torvalds",
});

// Delete the record
await db.delete("12345678");

// Clear the whole database
await db.clear();

Why this might not be a good idea/choice?

You see, this library works just by reading and sending messages in a particular format using MTProto API. And GramJS is used as the client library for it. There are rate limits. That's the only issue I'm seeing with this library. But, I don't think rate limits will be an issue for small scale applications, though. Hey, I am not really sure about this, but I think: if the API calls are hitting the limits frequently, your account may even get suspended.

"I am not as smart as the Telegram devs, but I'd put something in place that prevents such projects from succeeding at any meaningful scale :D" ~ (Not me)


MIT License (C) 2022, Dunkan
< โ™ฅ๏ธ & โ˜• >

You might also like...

Swaps active audio input device in OBS upon twitch chat channel point redemption.

Swaps active audio input device in OBS upon twitch chat channel point redemption.

OBS-Mic-Swapper Shortcuts Set up Program Description Example of Functionality FAQ Contact Info Set up Create an account on Twitch for your bot Make su

Nov 8, 2022

Trying 5 Redux Alternatives (Zustand, Recoil, Jotai, Rematch and Redux-Toolkit). Expalined on CoderOne Ytb channel

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Oct 3, 2022

Notify new channel created/renamed on Next-gen Slack platform

notify-new-channel Notify new channel created/renamed on Next-gen Slack platform Install Deploy and create triggers. slack deploy slack trigger create

Oct 10, 2022

A minimal e-commerce store using Gatsby, SANITY, Stripe, Use-Shopping-Cart and Netlify

๐Ÿช Gatsby Starter Stripemart Like a supermarket but for Stripe. No ongoing monthly costs. Perfect for artists, creators and independent builders doing

Nov 14, 2022

โšก It is a simplified database module with multiple functions that you can use simultaneously with sqlite, yaml, firebase and json.

Prisma Database Developed with ๐Ÿ’™ by Roxza โšก An easy, open source database ๐Ÿ“ฆ Installation npm i prisma.db --save yarn add prisma.db ๐Ÿ”ฎ Importing impo

Jan 3, 2023

A simple, easy to use and extendible JSON database.

A simple, easy to use and extendible JSON database.

Newton โš ๏ธ This package is under active development: Compatibility and APIs may change. A simple, easy to use and extendible JSON database. Table of co

Dec 6, 2022

A high-resolution local database that uses precise algorithms to easily record data in local files within a project with persistent JSON and YAML support designed to be easy to set up and use

A high-resolution local database that uses precise algorithms to easily record data in local files within a project with persistent JSON and YAML support designed to be easy to set up and use

About A high-resolution local database that uses precise algorithms to easily record data in local files within a project with persistent JSON and YML

Dec 28, 2022

Github follower notifier via telegram bot

โšก GitHub Follower Notifier ๐Ÿ˜‹ โšก Vars: ๐Ÿ”ฅ FEED: Go Here to get yours. DATABASE: Go HERE to create one. After creating Instance: Go to your Instance Go

Nov 25, 2021

@TGMusicfy - Minimalistic Telegram music search bot written in TypeScript and based on Telegraf and Express JS.

@TGMusicfy Go to bot Deployed thanks to Heroku and New-Relic Bots are special Telegram accounts designed to handle messages automatically. Users can i

Sep 13, 2022
Comments
Owner
Dunkan
console.log(3446)
Dunkan
Gatsby-starter-minimal-blog - Typography driven, feature-rich blogging theme with minimal aesthetics.

Gatsby-starter-minimal-blog - Typography driven, feature-rich blogging theme with minimal aesthetics. Includes tags/categories support and extensive features for code blocks such as live preview, line numbers, and line highlighting.

Priya Chakraborty 0 Jan 29, 2022
An exercise in building a very minimal (and very stupid) in-memory SQL-like database for educational purposes.

Stupid Database This is an exercise in building a very minimal (and very stupid) in-memory SQL-like database for educational purposes. None of this co

Fabio Akita 196 Dec 20, 2022
The Chat'Inn is a simple and minimal realtime chat application whose database is powered by firebase and firestore.

The Chat-in The Chat'Inn is a simple and minimal realtime chat application whose database is powered by firebase and firestore. The frontend part is c

Aswin Asok 11 Aug 8, 2022
Interplanetary Database: A Database built on top of IPFS and made immutable using Ethereum blockchain.

IPDB IPDB (Interplanetary Database) is a key/value store database built on top of IPFS (Interplanetary File System). Project is intended to be an MVP

turinglabs 8 Oct 6, 2022
Visualize, modify, and build your database with dbSpy! An open-source data modeling tool to facilitate relational database development.

Visualize, modify, and build your database with dbSpy! dbSpy is an open-source data modeling tool to facilitate relational database development. Key F

OSLabs 115 Dec 22, 2022
Code in Solidity like a PRO with Egor Gavrilov. Check out YouTube channel โ–ถ๏ธ

Code in Solidity like a PRO with Egor Gavrilov Check out YouTube channel youtube.com/EgorGavrilov Tutorials Perfect Solidity Stack It's easy to get st

Egor Gavrilov 53 Dec 19, 2022
You view the Twitch channel chat and you can access the details of the users who wrote during the viewing period.

Twitch Chat Web Page You view the Twitch channel chat and you can access the details of the users who wrote during the viewing period. Getting Started

Mert 6 Dec 13, 2022
Automatic Role Adder Is Usually Used In Coding Servers Which Give Access To Codes By Subbing To Their Channel So This Helps Them To Auto Role People :)

Automatic Role Adder Setup Guide Automatic Role Adder Is Usually Used In Coding Servers Which Give Access To Codes By Subbing To Their Channel So This

NotJust 25 Dec 23, 2022
A chatbot for the Deloitte CBO #under30s channel.

Harold Harold A chatbot for our favourite Slack channel at Deloitte. Explore the docs ยป View Demo ยท Report Bug ยท Request Feature Table of Contents Abo

Jim Kelly 6 Nov 3, 2022
multi-channel fulfillment at scale

Openship is an operations platform that enables multi-channel fulfillment Website ยท Documentation ยท Openship Cloud Running locally To get Openship run

openship 931 Dec 31, 2022