@ga-ut/gh-db
v0.0.2
Published
A Simple Data Management Tool Based on GitHub Issues
Readme
GHDB: A Simple Data Management Tool Based on GitHub Issues
GHDB is a simple class for managing data using GitHub issues. It allows you to create, read, update, and delete posts easily.
Installation
npm install @ga-ut/gh-dbyarn add @ga-ut/gh-dbpnpm add @ga-ut/gh-dbbun add @ga-ut/gh-dbUsage
This section demonstrates how to store and manage blog post information using GHDB.
Initialization
To use GHDB, you need a GitHub API token, repository owner, and repository name. If you only need to read data, you can set the token to null:
import { GHDB } from "@ga-ut/gh-db";
const db = new GHDB({
// Set to null for public read-only access
token: "YOUR_GITHUB_TOKEN",
owner: "YOUR_GITHUB_USERNAME",
repo: "YOUR_REPOSITORY_NAME",
});Create a Post
To create a new blog post:
const newPost = await db.create({
subject: "Blog",
data: {
title: "Blog Post Title",
content: "This is the content of the blog post.",
},
});Read Posts
To read all blog posts:
const posts = await db.readAll({ subject: "Blog" });Update a Post
To update an existing post:
await db.update(id, {
title: "Blog Post Title",
content: "Updated content.",
});Delete a Post
To delete a post:
await db.delete(id);License
This project is licensed under the MIT License.
