npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

github-gist-database

v1.0.14

Published

Unlimited GitHub Gist DB is a lightweight NoSQL database package for Node.js, designed to store JSON data in GitHub Gists, providing CRUD operations and more. Because it depends on the gists and Github says that you can create an unlimted gists and unlimi

Downloads

2

Readme

Unlimited GitHub Gist DB is a lightweight NoSQL database package for Node.js, designed to store JSON data in GitHub Gists, providing CRUD operations and more. Because it depends on the gists and Github says that you can create an unlimted gists and unlimited requests 🤑 for free.

🏠 Homepage

Table of Contents

Install

npm install github-gist-database

Usage

import { DB } from "github-gist-database";


// Define your Schema
const productSchema = new DB(
  {
    name: "String",
    price: "Number",
  },
  {
    githubToken: process.env.GITHUB_ACCESS_TOKEN!,
    schemaName: "productSchema",
    projectName: "test",
    gistId: "48ec463b54be5973729a108297860555",
    timeStamps: true,
  }
);




// Example usage
(async () => {
  const product = await productSchema.create({
    name: "laptop lenovo",
    price: 500,
  });
  console.log(product);

  const updatedProduct = await productSchema.findOneAndUpdate(
    { name: "iphone 15 pro max" },
    { name: "laptop Dell", price: 800 }
  );
  console.log(updatedProduct);

  const deletionStatus = await productSchema.findByIdAndDelete(
    "33a66454-fc9a-4016-bc01-45731fc16be3"
  );
  console.log(deletionStatus);
})();

Learn

First you have to define the Schema (the body of your database)

import { DB } from "github-gist-database";

// Define your schema
interface Product {
  name: string;
  price: number;
}

// Initialize the database
const productSchema = new DB<Product>(
  {
    name: "String",
    price: "Number",
  },
  {
    githubToken: process.env.GITHUB_ACCESS_TOKEN!,
    schemaName: "productSchema",
    projectName: "test",
    gistId: "48ec463b54be5973729a108297860555",
    timeStamps: true,
  }
);
1`
 {
    name: "String",
    price: "Number",
  },
  this is the fields and its types of your database
  you can define many fields as you want.
  And here is the types you can create with
    | "String"
    | "Number"
    | "Boolean"
    | "Object"
    | "Array"
    | "Undefined"
    | "Null"
    | "Symbol"
    | "BigInt"
`;
  1. githubToken: process.env.GITHUB_ACCESS_TOKEN!. your github access token you can create it in you Developer Settings

alt text alt text alt text alt text alt text

Only Check Gist alt text

And then click Generate Token alt text

This is your github Token

alt text

timeStamps: true 3. timeStamps: true, will add CreatedAt and updatedAT in your schema. whenever you create a new Document Example (new product) Example createdAt: '2024-03-04T12:35:52.641Z', updatedAt: '2024-03-04T12:35:52.643Z'

Create Method

const product = await productSchema.create({
  name: "laptop lenovo",
  price: 500,
});
console.log(product);
/*
  {
  name: 'laptop lenovo',
  price: 500,
  id: '16f1a00f-5527-4783-a966-29355aa5a9de',
  createdAt: '2024-03-04T12:35:52.641Z',
  updatedAt: '2024-03-04T12:35:52.643Z'
  }
  */

FindMany Method

console.log(await productSchema.findMany());
/*
  [
  {
    name: 'laptop lenovo',
    price: 500,
    id: '29ad41de-b015-4d96-a9d4-1a5c5a4a4ec7',
    createdAt: '2024-03-04T13:30:25.984Z',
    updatedAt: '2024-03-04T13:30:25.986Z'
  },
  {
    name: 'laptop lenovo',
    price: 500,
    id: '479a474b-a668-4407-8543-adcae24d9f91',
    createdAt: '2024-03-04T13:31:08.447Z',
    updatedAt: '2024-03-04T13:31:08.449Z'
  }
]
  */

FindFirst Method

console.log(await productSchema.findMany());
/*
  [
  {
    name: 'laptop lenovo',
    price: 500,
    id: '29ad41de-b015-4d96-a9d4-1a5c5a4a4ec7',
    createdAt: '2024-03-04T13:30:25.984Z',
    updatedAt: '2024-03-04T13:30:25.986Z'
  },
  {
    name: 'laptop lenovo',
    price: 500,
    id: '479a474b-a668-4407-8543-adcae24d9f91',
    createdAt: '2024-03-04T13:31:08.447Z',
    updatedAt: '2024-03-04T13:31:08.449Z'
  }
]
  */

FindByIdAndUpdate Method

console.log(
  await productSchema.findByIdAndUpdate(
    "29ad41de-b015-4d96-a9d4-1a5c5a4a4ec7",
    { name: "laptop Dell", price: 800 }
  )
);
/*
Before:
  {
    "name": "laptop lenovo",
    "price": 500,
    "id": "29ad41de-b015-4d96-a9d4-1a5c5a4a4ec7",
    "createdAt": "2024-03-04T13:30:25.984Z",
    "updatedAt": "2024-03-04T13:30:25.986Z"
  }

  After:
  {
  name: 'laptop Dell',
  price: 800,
  id: '29ad41de-b015-4d96-a9d4-1a5c5a4a4ec7',
  createdAt: '2024-03-04T13:30:25.984Z',
  updatedAt: '2024-03-05T21:54:15.440Z'
  }
  */

FindOneAndUpdate Method

console.log(
  await productSchema.findByIdAndUpdate(
    "29ad41de-b015-4d96-a9d4-1a5c5a4a4ec7",
    { name: "laptop Dell", price: 800 }
  )
);
/*
Before:
  {
  name: 'laptop Dell',
  price: 800,
  id: '29ad41de-b015-4d96-a9d4-1a5c5a4a4ec7',
  createdAt: '2024-03-04T13:30:25.984Z',
  updatedAt: '2024-03-05T21:54:15.440Z'
  }

  After:
  {
  name: 'laptop Dell 2',
  price: 800,
  id: '29ad41de-b015-4d96-a9d4-1a5c5a4a4ec7',
  createdAt: '2024-03-04T13:30:25.984Z',
  updatedAt: '2024-03-05T21:58:24.302Z'
  }
  */

FindByIdAndDelete Method

console.log(
  await productSchema.findByIdAndUpdate(
    "29ad41de-b015-4d96-a9d4-1a5c5a4a4ec7",
    { name: "laptop Dell", price: 800 }
  )
);
/*
Before:
  {
    name: 'laptop Dell 2',
    price: 800,
    id: '29ad41de-b015-4d96-a9d4-1a5c5a4a4ec7',
    createdAt: '2024-03-04T13:30:25.984Z',
    updatedAt: '2024-03-05T21:58:24.302Z'
  }

  After:
 Response "Ok"
  */

FindOneAndDelete Method

  console.log(
    await productSchema.findOneAndDelete({id:"479a474b-a668-4407-8543-adcae24d9f91"})
  );
/*
Before:
  {
    "name": "laptop lenovo",
    "price": 500,
    "id": "479a474b-a668-4407-8543-adcae24d9f91",
    "createdAt": "2024-03-04T13:31:08.447Z",
    "updatedAt": "2024-03-04T13:31:08.449Z"
  }

  After:
 Response "Ok"
  */

Author

👤 ElTahawy

🤝 Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2024 Amer Eltahawy. This project is MIT licensed.