-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from GuoXiCheng/dev-c
update readme
- Loading branch information
Showing
3 changed files
with
177 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
[简体中文](README.md) | ENGLISH | ||
|
||
# TinyCRUD | ||
|
||
![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/GuoXiCheng/TinyCRUD/ci.yml) | ||
![Codecov branch](https://img.shields.io/codecov/c/github/GuoXiCheng/TinyCRUD/main) | ||
|
||
## Introduction | ||
|
||
TinyCRUD is a lightweight data storage library based on the Issue API of the code hosting platform. It can use Issues as database tables, and Issue comments as records in these tables. It performs data serialization/deserialization through the Issue API to enable data addition, deletion, modification, and querying. | ||
|
||
## Applicable Scenarios | ||
|
||
TinyCRUD is suitable for small teams or personal projects that require simple and lightweight data storage, but do not want or need to set up a complex database system. | ||
|
||
## Supported code hosting platforms | ||
|
||
<table> | ||
<tr> | ||
<td> | ||
<p align="center"> | ||
<img src="https://guoxicheng.top/assets/image/tiny-crud-docs/github.svg" title="Github"/> | ||
</p> | ||
</td> | ||
<td> | ||
<p align="center"> | ||
<img src="https://guoxicheng.top/assets/image/tiny-crud-docs/gitlab.svg" title="Gitlab"/> | ||
</p> | ||
</td> | ||
<td> | ||
<p align="center"> | ||
<img src="https://guoxicheng.top/assets/image/tiny-crud-docs/gitee.svg" title="Gitee"/> | ||
</p> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
Github API latest | ||
</td> | ||
<td> | ||
Gitlab API v4 | ||
</td> | ||
<td> | ||
Gitee API v5 | ||
</td> | ||
</tr> | ||
</table> | ||
|
||
## Supported request libraries | ||
|
||
<table> | ||
<tr> | ||
<td> | ||
<img src="https://axios-http.com/assets/logo.svg" /> | ||
</td> | ||
<td> | ||
<p align="center"> | ||
<img src="https://guoxicheng.top/assets/image/tiny-crud-docs/wechat.svg" /> | ||
</p> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
axios | ||
</td> | ||
<td> | ||
wx(WeChat Mini Program) | ||
</td> | ||
</tr> | ||
</table> | ||
|
||
## Installation | ||
|
||
```shell | ||
npm install tiny-crud | ||
``` | ||
|
||
## Usage | ||
|
||
### Initialization | ||
|
||
```ts | ||
import axios from "axios"; | ||
import { createRequest } from "tiny-crud"; | ||
|
||
const GithubRequest = createRequest({ | ||
httpLib: "axios", | ||
httpClient: axios, | ||
accessToken: "Your Personal Access Token", | ||
|
||
platform: "github", | ||
owner: "Your Owner", | ||
repo: "Your Repo", | ||
}); | ||
``` | ||
|
||
### Create Model | ||
|
||
```ts | ||
import { BaseModel } from "tiny-crud"; | ||
|
||
export interface UserModel extends BaseModel { | ||
name: string; | ||
age: number; | ||
gender: string; | ||
} | ||
``` | ||
|
||
### Create Repository | ||
|
||
```ts | ||
import { GithubRepository } from "tiny-crud"; | ||
import { githubRequest } from "./github-request"; | ||
|
||
export class UserRepository extends GithubRepository<UserModel> { | ||
constructor() { | ||
super(githubRequest, "Your Issue Number"); | ||
} | ||
} | ||
``` | ||
|
||
### Basic Operations | ||
|
||
```ts | ||
const userRepository = new UserRepository(); | ||
|
||
// create data | ||
userRepository.create({ | ||
name: "John", | ||
age: 30, | ||
gender: "male", | ||
}); | ||
|
||
// find data | ||
userRepository.find(); | ||
|
||
// update data | ||
userRepository.updateById(1, { | ||
name: "Mary", | ||
age: 25, | ||
gender: "female", | ||
}); | ||
|
||
// delete data | ||
userRepository.deleteById(1); | ||
``` | ||
|
||
## Documentation | ||
|
||
- more detailed documentation 👉[TinyCRUD Docs](https://guoxicheng.top/en/projects/TinyCRUD-Docs) | ||
- If you find it helpful, please consider giving it a little star, and thank you for your support! 🌟 | ||
|
||
## License | ||
|
||
[MIT](https://github.com/GuoXiCheng/TinyCRUD/blob/main/LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters