TelegramAsDatabase 3.0.0

dotnet add package TelegramAsDatabase --version 3.0.0
                    
NuGet\Install-Package TelegramAsDatabase -Version 3.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TelegramAsDatabase" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TelegramAsDatabase" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="TelegramAsDatabase" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TelegramAsDatabase --version 3.0.0
                    
#r "nuget: TelegramAsDatabase, 3.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=TelegramAsDatabase&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=TelegramAsDatabase&version=3.0.0
                    
Install as a Cake Tool

TDB: Telegram as database service

This project is a .NET application that utilizes Telegram's free cloud storage to provide a simple, scalable database solution. It enables data storage and management through a Telegram bot, allowing users to interact with the database directly via Telegram. By leveraging Telegram's cloud infrastructure, the project eliminates the need for traditional database setups, offering a lightweight and efficient alternative for small to medium-scale data storage needs.

Now telegram as database is availabe on nuget.org: click here

Features

  1. Asynchronous Operations: All methods are asynchronous (using Task) to avoid blocking the calling thread.
  2. Transaction Support: Offers the ability to begin a transaction for atomic operations.
  3. Generic Interface: The interface is generic (ITDB) allowing it to work with various data types.
  4. Data Model: Uses a generic data model (TDBData<T>) to encapsulate data and metadata.
  5. FluentResults Integration: Leverages the FluentResults library for robust error handling and reporting.
  6. Cancellation Support: All methods accept an optional CancellationToken for graceful cancellation.
  7. Key-Value Storage: Primarily designed for key-value based data storage and retrieval.
  8. Basic CRUD Operations: Supports common operations like Get, Set, Update, Delete, and Exists.
  9. Bulk Operations: Includes methods for saving and deleting multiple items in bulk.
  10. Key Retrieval: Provides a method to retrieve all keys currently stored.
  11. Retry Policy: Implements a retry policy to enhance resilience against transient failures. This policy can be configured to retry operations a specified number of times with optional backoff strategies, improving the overall reliability and availability of the service.

Getting start

  1. Create a bot using bot father in telegram (Important: Dont Change the bot description at all)

    botfather

  2. Create a channel as a database source in telegram

    channel

  3. Now add your bot that created in the first step to the channel as an administrator and give all premissions to it.

    channel

  4. Goto your appsettings and add TDB config to it.:

    • The api key is key that you get from BotFather in the first step
    • The Channel Id is the id of the channel you can get it by forwarding a message of the channel to @userinfobot bot.
    "TDBConfig": {
        "ApiKey": "7753344678:AAFf4MIQSShxa4djp172DjhDe2_jqRsyOeU",
        "ChannelId": "-1002378130994"
    }
    
  5. Now Add Tdb to your service container:

    var configurations = builder.Configuration;
    builder.Services.AddTDB(configurations);
    
  6. Done! now you can use the telegram free database

How to use

The example code of using the TDB:

public class MyCustomService
{
    private ITDB _tdbService;

    public MyCustomService(ITDB tdb)
    {
        _tdbService = tdb;
    }

    public async Task MyCustomMethod(CancellationToken cancellationToken)
    {
        // [--------- GetAllKeysAsync ---------]
        var allKeys = await _tdbService.GetAllKeysAsync(cancellationToken);

        // [------------ SaveAsync ------------]
        var saveResult = await _tdbService.SaveAsync(new TDBData<MyTestModel>()
        {
            Key = "itemkey",
            Value = new MyTestModel()
            {
                Name = "FirstTest",
                Description = "FirstDescription",
                Type = "FuncTest"
            }
        }, cancellationToken);

        // [--------- UpdateAsync ---------]
        var updateResult = await _tdbService.UpdateAsync("itemkey", new TDBData<MyTestModel>()
        {
            Key = "itemkey",
            Value = new MyTestModel()
            {
                Name = "FirstTest2",
                Description = "FirstDescription2",
                Type = "FuncTest2"
            }
        }, cancellationToken);

        // [--------- DeleteAsync ---------]
        var deleteResult = await _tdbService.DeleteAsync("itemkey", cancellationToken);
    }
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0 121 1/4/2025
2.2.0 104 12/21/2024
2.1.0 104 12/19/2024
2.0.0 94 12/19/2024

Initial Release