Skip to content

Commit

Permalink
Merge pull request #91 from GuoXiCheng/dev-c
Browse files Browse the repository at this point in the history
update readme
  • Loading branch information
GuoXiCheng authored Jan 24, 2024
2 parents d90a0f4 + efb5264 commit ffc3fe8
Show file tree
Hide file tree
Showing 3 changed files with 177 additions and 7 deletions.
155 changes: 155 additions & 0 deletions README.en.md
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)
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
简体中文 | [English](README.en.md)

# TinyCRUD

![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/GuoXiCheng/TinyCRUD/ci.yml)
Expand Down Expand Up @@ -33,13 +35,13 @@ TinyCRUD 适合用于满足小型团队或个人项目中需要简单、轻量
</tr>
<tr>
<td>
API latest
Github API latest
</td>
<td>
API v4
Gitlab API v4
</td>
<td>
API v5
Gitee API v5
</td>
</tr>
</table>
Expand All @@ -59,10 +61,10 @@ TinyCRUD 适合用于满足小型团队或个人项目中需要简单、轻量
</tr>
<tr>
<td>
<p align="center">axios</p>
<p align="center">axios</p>
</td>
<td>
wx(微信小程序)
wx(微信小程序)
</td>
</tr>
</table>
Expand Down Expand Up @@ -144,7 +146,7 @@ userRepository.updateById(1, {
userRepository.deleteById(1);
```

## 说明
## 详细文档

* 更好的阅读体验以及详细的使用文档请戳 👉[TinyCRUD Docs](https://guoxicheng.top/projects/TinyCRUD-Docs/)
* 如果对你有帮助的话可以给颗小星星,感谢支持!🌟
Expand Down
15 changes: 14 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tiny-crud",
"version": "1.1.0",
"description": "A tiny CRUD library based on Git Issue API",
"description": "Lightweight Data Repository Based on Git Issue API",
"main": "dist/bundle.cjs.js",
"module": "dist/bundle.esm.js",
"types": "dist/index.d.ts",
Expand All @@ -17,6 +17,19 @@
"dist/bundle.esm.js",
"dist/index.d.ts"
],
"keywords": [
"git",
"issue",
"crud",
"data",
"repository",
"api"
],
"homepage": "https://guoxicheng.top/projects/TinyCRUD-Docs",
"repository": {
"type": "git",
"url": "https://github.com/GuoXiCheng/TinyCRUD.git"
},
"devDependencies": {
"@babel/preset-env": "^7.23.3",
"@babel/preset-typescript": "^7.23.3",
Expand Down

0 comments on commit ffc3fe8

Please sign in to comment.