Skip to content

Commit

Permalink
Docs: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
asheswook committed Feb 11, 2025
1 parent 08dbf2a commit 6746bc1
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 21 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ It is designed to provide reliable and intuitive transaction management for miss

**This framework is now experimental and under development. Please feel free to contribute or provide feedback.**

## Features
-**Effortless Declarative Transactions** – Manage complex DB transactions with a single line of code!
-**TypeScript Native** – Seamless and powerful TypeScript support for the best development experience!
- 🛠️ **No Dependencies, Lightweight (40KB)** – Runs fast with zero unnecessary bloat!
- 🔄 **Flexible Transaction Propagation** – Supports propagation modes like `MANDATORY`, `REQUIRES_NEW`.

## Getting Started
* API Documentation is available at [here](/docs/api.md).
* The [example](/examples) contains a simple example of how to use the TranJS framework.
Expand Down Expand Up @@ -53,11 +59,6 @@ Execute Query Chansu 100
Commit Transaction (id: ae8wml5i78rt) # Transaction committed when transfer() finished
```

## Feature
* Provide declarative database transaction
* Typescript Native
* No dependencies

## The reason why made this
While developing software requiring robust transaction management, I needed a way to group multiple query executions into a single transaction. Initially, I used anonymous functions, referred to as _Executables_, to achieve this. However, this approach was complex, required extra boilerplate code, and made it difficult for new developers to understand.

Expand Down
45 changes: 34 additions & 11 deletions docs/drivers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

## Supported Drivers

### [MySQL Driver](#MySQL-Driver)
### [MySQL Drivers](#MySQL-Driver)
- [mysql2](https://npmjs.com/package/mysql2)
- Use the `@tranjs/mysql2` package to integrate with MySQL databases.

### [PostgreSQL Driver](#PostgreSQL-Driver)
### [PostgreSQL Drivers](#PostgreSQL-Driver)
- [pg](https://npmjs.com/package/pg)
- Use the `@tranjs/pg` package to integrate with PostgreSQL databases.

Expand All @@ -22,18 +22,28 @@ npm install @tranjs/core @tranjs/mysql2 --save

```typescript
import { createPool } from "mysql2/promise";
import { MySQLTransactionManager } from "@tranjs/mysql2";
import { useTransactionManager } from "@tranjs/core";
import { useMySQLTransactionManager } from "@tranjs/mysql2";

const pool = createPool({
host: 'localhost',
port: 3306,
user: 'admin',
password: 'password',
database: 'mydb',
})

useTransactionManager(new MySQLTransactionManager(pool));
// Don't need to `useTransactionManager`,
// if you use `useMySQLTransactionManager`
useMySQLTransactionManager(pool);
```

```typescript
import { Transactional } from "@tranjs/core";
import { ctx } from "@tranjs/mysql2";

class MyService {
@Transactional()
async method() {
await ctx().execute("SELECT 1;")
}
}
```

That’s it! You’re ready to use TranJS with MySQL.
Expand All @@ -50,15 +60,28 @@ npm install @tranjs/core @tranjs/pg --save

```typescript
import { Pool } from "pg";
import { PostgreSQLTransactionManager } from "@tranjs/pg";
import { useTransactionManager } from "@tranjs/core";
import { usePostgreSQLTransactionManager } from "@tranjs/pg";

const pool = new Pool({
host: 'localhost',
user: 'database-user',
})

useTransactionManager(new PostgreSQLTransactionManager(pool));
// Don't need to `useTransactionManager`,
// if you use `usePostgreSQLTransactionManager`
usePostgreSQLTransactionManager(pool);
```

```typescript
import { Transactional } from "@tranjs/core";
import { ctx } from "@tranjs/pg";

class MyService {
@Transactional()
async method() {
await ctx().execute("SELECT 1;")
}
}
```

That’s it! You’re ready to use TranJS with PostgreSQL.
Expand Down
11 changes: 6 additions & 5 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ It is designed to provide reliable and intuitive transaction management for miss

**This framework is now experimental and under development. Please feel free to contribute or provide feedback.**

## Features
-**Effortless Declarative Transactions** – Manage complex DB transactions with a single line of code!
-**TypeScript Native** – Seamless and powerful TypeScript support for the best development experience!
- 🛠️ **No Dependencies, Lightweight (40KB)** – Runs fast with zero unnecessary bloat!
- 🔄 **Flexible Transaction Propagation** – Supports propagation modes like `MANDATORY`, `REQUIRES_NEW`.

## Getting Started
* API Documentation is available at [here](/docs/api.md).
* The [example](/examples) contains a simple example of how to use the TranJS framework.
Expand Down Expand Up @@ -53,11 +59,6 @@ Execute Query Chansu 100
Commit Transaction (id: ae8wml5i78rt) # Transaction committed when transfer() finished
```

## Feature
* Provide declarative database transaction
* Typescript Native
* No dependencies

## The reason why made this
While developing software requiring robust transaction management, I needed a way to group multiple query executions into a single transaction. Initially, I used anonymous functions, referred to as _Executables_, to achieve this. However, this approach was complex, required extra boilerplate code, and made it difficult for new developers to understand.

Expand Down

0 comments on commit 6746bc1

Please sign in to comment.