Skip to content

Latest commit

 

History

History
155 lines (122 loc) · 3.44 KB

README.en.md

File metadata and controls

155 lines (122 loc) · 3.44 KB

简体中文 | ENGLISH

TinyCRUD

GitHub Workflow Status (with event) Codecov branch

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

npm install tiny-crud

Usage

Initialization

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

import { BaseModel } from "tiny-crud";

export interface UserModel extends BaseModel {
    name: string;
    age: number;
    gender: string;
}

Create Repository

import { GithubRepository } from "tiny-crud";
import { githubRequest } from "./github-request";

export class UserRepository extends GithubRepository<UserModel> {
    constructor() {
        super(githubRequest, "Your Issue Number");
    }
}

Basic Operations

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
  • If you find it helpful, please consider giving it a little star, and thank you for your support! 🌟

License

MIT