diff --git a/README.md b/README.md index b67a72e..e4b7e71 100644 --- a/README.md +++ b/README.md @@ -3,5 +3,152 @@ ![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);