Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wpdas/chain-db

Chain DB is a history-driven database. A DB where you can create HistoryTables, persist new data and fetch the history of the table.
https://github.com/wpdas/chain-db

block chain database db

Last synced: about 1 month ago
JSON representation

Chain DB is a history-driven database. A DB where you can create HistoryTables, persist new data and fetch the history of the table.

Awesome Lists containing this project

README

        

Chain DB


History-driven Database





About
|
Download
|
Libraries


Chain DB is a history-driven database. This system uses a chain of blocks with stored data. Each change generates a transaction that is saved in a block. The network works centrally, so persistent data is not decentralized.

The generated blocks are immutable. New data or updated data are saved in newer blocks, in this way, it is possible to recover all data from a table throughout its life.

This database has some features by default, such as: create user account, get user account, transfer units and get transfer records as well as the main feature that is tables.

The `unit` property present in each user's account can be anything the project wants, it can be a type of currency, item, resource.

We are just at the beginning of the implementation of this database. Let me know if you want to contribute to this project, contact me here or via my email: [email protected].

## Download

Go to [Releases](https://github.com/wpdas/chain-db/releases) page and download the binary according to the desired architecture.

| Binary | OS | Devices |
| ------------------------------------------------------------------------------------------------ | --------- | ------------------------------------ |
| [chain-db-osx](https://github.com/wpdas/chain-db/releases/download/0.0.3-alpha/chain-db-osx) | macOS 11+ | Apple |
| [chain-db-arm64](https://github.com/wpdas/chain-db/releases/download/0.0.3-alpha/chain-db-arm64) | Linux | Raspberry Pi3, Raspberry Pi4, Others |

## Libraries (client)

Below are links to libraries (client) to be used with your preferred programming language.

Although some libraries work on the client side, it is recommended to use it on the server side since it is a database transiting sensitive data.

| Platform | Repository |
| ---------------------- | --------------------------------------------------- |
| Rust | [chain-db-rs](https://github.com/wpdas/chain-db-rs) |
| TypeScript, JavaScript | [chain-db-ts](https://github.com/wpdas/chain-db-ts) |

## Temporary Server (test)

Use this server to test ChainDB while testing your application or while creating a new Client.

**Chain DB Test Server:** https://gull-dominant-mistakenly.ngrok-free.app. This server may not be always available.

**Rust using `chain-db-rs`:**

```rs
#[tokio::main]
async fn main() {
// 1 - DB connection: server | db-name | user | password
let db = ChainDB::connect(Some("https://gull-dominant-mistakenly.ngrok-free.app"), "test-db", "root", "1234");

// 2 - Init a table
let mut greetingTable = db.get_table("greeting", GreetingTable::new).await;
println!("{:?}", greetingTable.table.greeting); // "Hi"

// 3 - Mutate the table values and persist on chain
greetingTable.table.greeting = String::from("Hello my dear!");
greetingTable.persist().await; // Persist data on chain

// 4 - See the most updated values of the table
println!("{:?}", greetingTable.table.greeting); // "Hello my dear!"
}
```

**TypeScript / JavaScript using `chain-db-ts`:**

```ts
import { connect } from 'chain-db-ts'
import { GreetingTable } from './tables'

const main async () {
// 1 - DB connection: server | db-name | user | password
const db = connect("https://gull-dominant-mistakenly.ngrok-free.app", 'test-db', 'root', '1234')

// 2 - Init a table
const greetingTable = await db.get_table('greeting', new GreetingTable())
console.log(greetingTable.table.greeting) // 'Hi'

// 3 - Mutate the table values and persist on chain
greetingTable.table.greeting = "Hello my dear!"
await greetingTable.persist() // Data is persisted on the blockchain

// 4 - See the most updated values of the table
console.log(greetingTable.table.greeting) // 'Hello my dear!'
}
main()
```