Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@terencesun/githubdb

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@terencesun/githubdb

operate with github like mongodb for nodejs

  • 1.0.9
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
318
increased by9.28%
Maintainers
1
Weekly downloads
 
Created
Source

GithubDB by TerenceSun


A lightweight GitHub database operator, let your GitHub repo like mongodb

Usage

npm install @terencesun/githubdb
import { GithubDb } from "@terence/githubdb";

async function main() {
        const githubdb = new GithubDb({
                token: "<your GitHub token, generat from https://github.com/settings/tokens>",
                owner: "<your username, like db server name>",
                repo: "<your repository to store the db's data, like database name>",    // Suggest that repo be private
                path: "<your file path in the repository to store the db's data, like table name>",
                branch: "<your repository's branch you can choose, optional, default is your default branch>"
        });
        
        // NOTE: the programe will create the branch you set if you branch is not created, and the base sha is the latest default branch commit
        // if you don't want the behavior, you should create the branch by yourself
        
        // connect to db, if the repo or path is not exist, here will create them
        await githubdb.connect();
        
        // insert operations, insertOne/insertMany
        await githubdb.insertOne({ test: 1 });
        await githubdb.insertMany([ { test: 1, test2: 2 }, { test3: 3 } ]);
        
        // delete operations, deleteOne/deleteMany
        await githubdb.deleteOne({ test: 1 });
        await githubdb.deleteMany({ test: 1 });
        
        // update operations, updateOne/updateMany, here is not the options like mongodb's update operation
        await githubdb.updateOne({ test: 1 }, { $set: { test2: 123 } });
        await githubdb.updateMany({ test: 1 }, { $set: { test2: 123 } });
        
        // find operations, find, only one method here
        await githubdb.find({ test: 1 });
        
        /*
        * Support Operators
        * Query Operators: $eq/$gt/$gte/$lt/$lte/$ne/$in/$nin/$exists/$and/$or/$not/$geoWithin/$geoIntersects/$near
        * Update Operators: $inc/$mul/$rename/$set/$unset/$min/$max/$currentDate/$pop/$pullAll/$pull/$push
        * - Array Update Operator Modifiers: $each/$slice/$position
        * - Array Update Comparison Operators: $eq/$gt/$gte/$lt/$lte/$ne/$in/$nin
        * Powered by https://github.com/jclo/picodb
        * thx so much
        * */
        
        // All the methods and operators is above
}

main();

Performance

We all use GitHub as a database, so, Low performance, but can be used to record some small things

Licence

MIT

FAQs

Package last updated on 29 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc