From 13c0cfcb8decda93021e2958216389e6bb2c85b1 Mon Sep 17 00:00:00 2001 From: GuoXiCheng <1377994267@qq.com> Date: Mon, 22 Jan 2024 21:50:43 +0800 Subject: [PATCH 1/7] update readme --- README.md | 138 ++++++++++++++++++ package.json | 2 +- src/repository-lib/gitee/gitee-repository.ts | 4 + .../github/github-repository.ts | 3 + .../gitlab/gitlab-repository.ts | 4 +- 5 files changed, 149 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b67a72e..812d761 100644 --- a/README.md +++ b/README.md @@ -3,5 +3,143 @@ ![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) +TinyCRUD 是一个基于代码托管平台 Issue API 的轻量级数据存储库,它可以将 Issue 作为数据库表,Issue 的评论作为数据表记录,通过 Issue API 将数据序列化/反序列化,实现数据的增删改查。 + +## 适用场景 + +TinyCRUD 适合用于满足小型团队或个人项目中需要简单、轻量级数据存储,但又不想或不需要设置复杂数据库系统的情况。 + +## 支持的代码托管平台 + + + + + + + + + + + + +
+ + + + + +
+ API latest ✔ + + API v4 ✔ + + API v5 ✔ +
+ +## 支持的请求库 + + + + + + + + + + +
+ + + +
+ axios ✔ + + wx(微信小程序) ✔ +
+ +## 安装 + +```bash +npm install tiny-crud +``` + +## 使用 + +### 创建请求 + +```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", +}); +``` + +### 创建数据模型 + +```ts +import { BaseModel } from "tiny-crud"; + +export interface UserModel extends BaseModel { + name: string; + age: number; + gender: string; +} +``` + +### 创建数据存储库 + +```ts +import { GithubRepository } from "tiny-crud"; +import { githubRequest } from "./github-request"; + +export class UserRepository extends GithubRepository { + constructor() { + super(githubRequest, "Your Issue Number"); + } +} +``` + +### 数据存储操作 + +```ts +const userRepository = new UserRepository(); + +// 创建数据 +userRepository.create({ + name: "John", + age: 30, + gender: "male", +}); + +// 查询数据 +userRepository.find(); + +// 更新数据 +userRepository.updateById(1, { + name: "Mary", + age: 25, + gender: "female", +}); + +// 删除数据 +userRepository.deleteById(1); +``` + +## 说明 + +- 更好的阅读体验以及详细的使用文档请戳 👉[TinyCRUD Docs](https://guoxicheng.top/projects/TinyCRUD-Docs/) +- 如果对你有帮助的话可以给颗小星星,感谢支持!🌟 + +## License + +[MIT](https://github.com/GuoXiCheng/TinyCRUD/blob/main/LICENSE) diff --git a/package.json b/package.json index e9f6ade..5214362 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tiny-crud", - "version": "1.0.24", + "version": "1.1.0", "description": "A tiny CRUD library based on Git Issue API", "main": "dist/bundle.cjs.js", "module": "dist/bundle.esm.js", diff --git a/src/repository-lib/gitee/gitee-repository.ts b/src/repository-lib/gitee/gitee-repository.ts index d48b01a..2cacbd8 100644 --- a/src/repository-lib/gitee/gitee-repository.ts +++ b/src/repository-lib/gitee/gitee-repository.ts @@ -18,6 +18,10 @@ export class GiteeRepository extends BaseRepository { /** * Finds items in the Gitee repository. * @param params - Optional parameters for the search. + * @param params.since - Only issues updated at or after this time are returned. + * @param params.page - The page number to retrieve. + * @param params.per_page - The number of items to retrieve per page.default: 20, maximum: 100 + * @param params.order - The sort order of the results.Either 'asc' or 'desc'. * @returns A promise that resolves to an array of items. */ async find(params?: GiteeParams): Promise { diff --git a/src/repository-lib/github/github-repository.ts b/src/repository-lib/github/github-repository.ts index ecd5485..246eb93 100644 --- a/src/repository-lib/github/github-repository.ts +++ b/src/repository-lib/github/github-repository.ts @@ -18,6 +18,9 @@ export class GithubRepository extends BaseRepository { /** * Finds items in the GitHub repository. * @param params - Optional parameters for the search. + * @param params.since - Only issues updated at or after this time are returned. + * @param params.page - The page number to retrieve. + * @param params.per_page - The number of items to retrieve per page.default: 30, maximum: 100 * @returns A promise that resolves to an array of items. */ async find(params?: GithubParams): Promise { diff --git a/src/repository-lib/gitlab/gitlab-repository.ts b/src/repository-lib/gitlab/gitlab-repository.ts index 8b264f8..6fbf11a 100644 --- a/src/repository-lib/gitlab/gitlab-repository.ts +++ b/src/repository-lib/gitlab/gitlab-repository.ts @@ -35,7 +35,9 @@ export class GitlabRepository extends BaseRepository { /** * Finds items in the Gitlab storage based on the provided parameters. * @param params - Optional parameters for the find operation. - * @returns A promise that resolves to an array of items found in the Gitlab storage. + * @param params.sort - Return requests sorted in asc or desc order. Default is desc. + * @param params.order_by - Return requests ordered by created_at or updated_at fields. Default is created_at. + * @returns A promise that resolves to an array of items. */ async find(params?: GitlabParams): Promise { const url = this.getRoute(RouteType.find); From e6a3719f10a403ef33a5b7b4b6bbab55332d2281 Mon Sep 17 00:00:00 2001 From: GuoXiCheng <1377994267@qq.com> Date: Mon, 22 Jan 2024 21:53:03 +0800 Subject: [PATCH 2/7] update readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 812d761..7ca36da 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ ![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) +## 介绍 + TinyCRUD 是一个基于代码托管平台 Issue API 的轻量级数据存储库,它可以将 Issue 作为数据库表,Issue 的评论作为数据表记录,通过 Issue API 将数据序列化/反序列化,实现数据的增删改查。 ## 适用场景 From 94aebecb2c3e19c3422a226b8140f52d2521a4d2 Mon Sep 17 00:00:00 2001 From: GuoXiCheng <1377994267@qq.com> Date: Mon, 22 Jan 2024 21:57:48 +0800 Subject: [PATCH 3/7] update readme --- README.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7ca36da..57870a7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # 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) ## 介绍 @@ -14,6 +15,7 @@ TinyCRUD 适合用于满足小型团队或个人项目中需要简单、轻量 ## 支持的代码托管平台 + +
@@ -36,17 +38,20 @@ TinyCRUD 适合用于满足小型团队或个人项目中需要简单、轻量 API v5 ✔
## 支持的请求库 - +
@@ -57,12 +62,14 @@ TinyCRUD 适合用于满足小型团队或个人项目中需要简单、轻量 wx(微信小程序) ✔ +
- +

+ +

## 安装 ```bash npm install tiny-crud + ``` ## 使用 @@ -137,11 +144,9 @@ userRepository.deleteById(1); ## 说明 -- 更好的阅读体验以及详细的使用文档请戳 👉[TinyCRUD Docs](https://guoxicheng.top/projects/TinyCRUD-Docs/) -- 如果对你有帮助的话可以给颗小星星,感谢支持!🌟 +* 更好的阅读体验以及详细的使用文档请戳 👉[TinyCRUD Docs](https://guoxicheng.top/projects/TinyCRUD-Docs/) +* 如果对你有帮助的话可以给颗小星星,感谢支持!🌟 ## License [MIT](https://github.com/GuoXiCheng/TinyCRUD/blob/main/LICENSE) - - From 7cc1744c534f16188fb88df4bcc52c8533c7c788 Mon Sep 17 00:00:00 2001 From: GuoXiCheng <1377994267@qq.com> Date: Mon, 22 Jan 2024 22:00:08 +0800 Subject: [PATCH 4/7] update readme --- README.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 57870a7..b206e1c 100644 --- a/README.md +++ b/README.md @@ -15,16 +15,21 @@ TinyCRUD 适合用于满足小型团队或个人项目中需要简单、轻量 ## 支持的代码托管平台 - @@ -38,12 +43,11 @@ TinyCRUD 适合用于满足小型团队或个人项目中需要简单、轻量 API v5 ✔ -
- +

+ +

- +

+ +

- +

+ +

## 支持的请求库 - +
-
@@ -62,7 +66,6 @@ TinyCRUD 适合用于满足小型团队或个人项目中需要简单、轻量 wx(微信小程序) ✔
## 安装 From 8ce72cbc99f65c1fecf5d83ea7ef710d6f7039d3 Mon Sep 17 00:00:00 2001 From: GuoXiCheng <1377994267@qq.com> Date: Mon, 22 Jan 2024 22:01:53 +0800 Subject: [PATCH 5/7] update readme --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b206e1c..3b2a7c8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # 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) ## 介绍 @@ -14,7 +13,7 @@ TinyCRUD 适合用于满足小型团队或个人项目中需要简单、轻量 ## 支持的代码托管平台 - +

@@ -47,7 +46,7 @@ TinyCRUD 适合用于满足小型团队或个人项目中需要简单、轻量 ## 支持的请求库 - +
From 17bdc730be9d4a313e016b7ce9f12c202d0e09bd Mon Sep 17 00:00:00 2001 From: GuoXiCheng <1377994267@qq.com> Date: Mon, 22 Jan 2024 22:07:15 +0800 Subject: [PATCH 7/7] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 04d6adc..e4b7e71 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ export class UserRepository extends GithubRepository { } ``` -### 数据存储操作 +### 基本操作 ```ts const userRepository = new UserRepository();
@@ -60,7 +59,7 @@ TinyCRUD 适合用于满足小型团队或个人项目中需要简单、轻量
- axios ✔ +

axios ✔

wx(微信小程序) ✔ From b0da910094728c48cfd17f839cfc597f6beb3d2e Mon Sep 17 00:00:00 2001 From: GuoXiCheng <1377994267@qq.com> Date: Mon, 22 Jan 2024 22:05:05 +0800 Subject: [PATCH 6/7] update readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3b2a7c8..04d6adc 100644 --- a/README.md +++ b/README.md @@ -17,17 +17,17 @@ TinyCRUD 适合用于满足小型团队或个人项目中需要简单、轻量

- +

- +

- +