Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/guoxicheng/tinycrud

基于 Issue API 的轻量级数据存储库 - Lightweight Data Repository Based on Git Issue API
https://github.com/guoxicheng/tinycrud

crud data-storage issue lightweight typescript

Last synced: 7 days ago
JSON representation

基于 Issue API 的轻量级数据存储库 - Lightweight Data Repository Based on Git Issue API

Awesome Lists containing this project

README

        

[简体中文](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





















Github API latest


Gitlab API v4


Gitee API v5

## Supported request libraries













axios


wx(WeChat Mini Program)

## 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 {
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://tinycrud.guoxicheng.top)
- 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)