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

grud

v1.0.12

Published

Simple JSON data store in GitHub for Node, Electron and the browser.

Downloads

34

Readme

Simple JSON data store in GitHub with CRUD interface for React, Node, Electron and the browser. grud is a convenient method of storing & performing read, update & delete operations on data without setting up a database server.

🏠 Homepage

Install

npm install grud

Initialize

To get started with grud, initialize the db object by passing the required config.

const Grud = require("grud");

let config = {
  protocol: "https",           //If not passed, defaults to 'https'
  host: "api.github.com",      //If not passed, defaults to 'api.github.com' | In case of Enterprise-GitHub e.g github.snapcircle.net.
  pathPrefix: "",              //Leave empty if you are using github.com | In case of Enterprise-GitHub e.g api/v3
  owner: "username",           //Your GitHub username
  repo: "my-repo",             //Your repository name where you'd like to have your JSON store hosted
  path: "db.json",             //Your data store file with .json extension
  personalAccessToken: "xxxx", //Your personal-access-token with write access
};
let db = new Grud(config);

Create your GitHub personal token from here. And please note that grud will create a new JSON data store file as mentioned in the config (db.json in our case) if the file is not found. If the file exists, data shall get appended to the collection array.

Create

Create a single record

The following query creates a single post record in your JSON dataStore (db.json).

const data = {
  author: "Anand",
  title: "sunt aut facere repellat provident ",
  body: "quia et suscipit\nsuscipit recusandae consequuntur ",
};
const posts = await db.save(data);

Create multiple records

The following query creates multiple post records in your defined JSON datastore.

const data = [
  {
    author: "Sarath",
    title: "sunt aut facere repellat provident ",
    body: "quia et suscipit\nsuscipit recusandae consequuntur ",
  },
  {
    author: "Anand",
    title: "qui est esse",
    body: "est rerum tempore vitae\nsequi sint nihil",
  },
];
const posts = await db.save(data);

Read

Get record by Id or unique identifier

The following query returns a single post record by unique identifier or Id.

const post = await db.find({ _id: "301b63faac384a31b3e785ebf40295e5" });

or

const post = await db.find({ author: "Anand" });

Get all records

The following query returns all posts records.

const posts = await db.find();

Update

Update record by Id or unique identifier. The following query finds the post record and updates it.

const posts = await db.update(
  { _id: "301b63faac384a31b3e785ebf40295e5" },
  data
);

or

const posts = await db.update({ author: "Anand" }, data);

Delete

Delete a single record

The following query deletes a single post record.

await db.deleteOne({ _id: "301b63faac384a31b3e785ebf40295e5" });

or

await db.deleteOne({ author: "Anand" });

Delete all records

TBA

Run tests

npm run test

🤝 Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page. You can also take a look at the contributing guide.

Show your support

Give a ⭐️ if this project helped you!

Limits

grud came out from the frequent need of having a database for internal tooling purpose. If your priority is to have secure/high-performance storage, you should stick to traditional databases like MongoDB.

Author

👤 Anees Ahammed

📝 License

Copyright © 2021 Anees Ahammed. This project is MIT licensed.