简体中文 | English
TinyCRUD 是一个基于代码托管平台 Issue API 的轻量级数据存储库,它可以将 Issue 作为数据库表,Issue 的评论作为数据表记录,通过 Issue API 将数据序列化/反序列化,实现数据的增删改查。
TinyCRUD 适合用于满足小型团队或个人项目中需要简单、轻量级数据存储,但又不想或不需要设置复杂数据库系统的情况。
Github API latest | Gitlab API v4 | Gitee API v5 |
axios |
wx(微信小程序) |
npm install tiny-crud
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",
});
import { BaseModel } from "tiny-crud";
export interface UserModel extends BaseModel {
name: string;
age: number;
gender: string;
}
import { GithubRepository } from "tiny-crud";
import { githubRequest } from "./github-request";
export class UserRepository extends GithubRepository<UserModel> {
constructor() {
super(githubRequest, "Your Issue Number");
}
}
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
- 如果对你有帮助的话可以给颗小星星,感谢支持!🌟