Skip to content

Commit 6746bc1

Browse files
committed
Docs: update docs
1 parent 08dbf2a commit 6746bc1

File tree

3 files changed

+46
-21
lines changed

3 files changed

+46
-21
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ It is designed to provide reliable and intuitive transaction management for miss
99

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

12+
## Features
13+
-**Effortless Declarative Transactions** – Manage complex DB transactions with a single line of code!
14+
-**TypeScript Native** – Seamless and powerful TypeScript support for the best development experience!
15+
- 🛠️ **No Dependencies, Lightweight (40KB)** – Runs fast with zero unnecessary bloat!
16+
- 🔄 **Flexible Transaction Propagation** – Supports propagation modes like `MANDATORY`, `REQUIRES_NEW`.
17+
1218
## Getting Started
1319
* API Documentation is available at [here](/docs/api.md).
1420
* The [example](/examples) contains a simple example of how to use the TranJS framework.
@@ -53,11 +59,6 @@ Execute Query Chansu 100
5359
Commit Transaction (id: ae8wml5i78rt) # Transaction committed when transfer() finished
5460
```
5561

56-
## Feature
57-
* Provide declarative database transaction
58-
* Typescript Native
59-
* No dependencies
60-
6162
## The reason why made this
6263
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.
6364

docs/drivers.md

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
## Supported Drivers
44

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

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

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

2323
```typescript
2424
import { createPool } from "mysql2/promise";
25-
import { MySQLTransactionManager } from "@tranjs/mysql2";
26-
import { useTransactionManager } from "@tranjs/core";
25+
import { useMySQLTransactionManager } from "@tranjs/mysql2";
2726

2827
const pool = createPool({
2928
host: 'localhost',
30-
port: 3306,
3129
user: 'admin',
32-
password: 'password',
33-
database: 'mydb',
3430
})
3531

36-
useTransactionManager(new MySQLTransactionManager(pool));
32+
// Don't need to `useTransactionManager`,
33+
// if you use `useMySQLTransactionManager`
34+
useMySQLTransactionManager(pool);
35+
```
36+
37+
```typescript
38+
import { Transactional } from "@tranjs/core";
39+
import { ctx } from "@tranjs/mysql2";
40+
41+
class MyService {
42+
@Transactional()
43+
async method() {
44+
await ctx().execute("SELECT 1;")
45+
}
46+
}
3747
```
3848

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

5161
```typescript
5262
import { Pool } from "pg";
53-
import { PostgreSQLTransactionManager } from "@tranjs/pg";
54-
import { useTransactionManager } from "@tranjs/core";
63+
import { usePostgreSQLTransactionManager } from "@tranjs/pg";
5564

5665
const pool = new Pool({
5766
host: 'localhost',
5867
user: 'database-user',
5968
})
6069

61-
useTransactionManager(new PostgreSQLTransactionManager(pool));
70+
// Don't need to `useTransactionManager`,
71+
// if you use `usePostgreSQLTransactionManager`
72+
usePostgreSQLTransactionManager(pool);
73+
```
74+
75+
```typescript
76+
import { Transactional } from "@tranjs/core";
77+
import { ctx } from "@tranjs/pg";
78+
79+
class MyService {
80+
@Transactional()
81+
async method() {
82+
await ctx().execute("SELECT 1;")
83+
}
84+
}
6285
```
6386

6487
That’s it! You’re ready to use TranJS with PostgreSQL.

packages/core/README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ It is designed to provide reliable and intuitive transaction management for miss
99

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

12+
## Features
13+
-**Effortless Declarative Transactions** – Manage complex DB transactions with a single line of code!
14+
-**TypeScript Native** – Seamless and powerful TypeScript support for the best development experience!
15+
- 🛠️ **No Dependencies, Lightweight (40KB)** – Runs fast with zero unnecessary bloat!
16+
- 🔄 **Flexible Transaction Propagation** – Supports propagation modes like `MANDATORY`, `REQUIRES_NEW`.
17+
1218
## Getting Started
1319
* API Documentation is available at [here](/docs/api.md).
1420
* The [example](/examples) contains a simple example of how to use the TranJS framework.
@@ -53,11 +59,6 @@ Execute Query Chansu 100
5359
Commit Transaction (id: ae8wml5i78rt) # Transaction committed when transfer() finished
5460
```
5561

56-
## Feature
57-
* Provide declarative database transaction
58-
* Typescript Native
59-
* No dependencies
60-
6162
## The reason why made this
6263
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.
6364

0 commit comments

Comments
 (0)