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

sagdb

v2.3.0

Published

Local json database.

Downloads

58

Readme

Sagdb

Image Image

Image

Sagdb is JSON database system.

Installation

$ npm install sagdb

Usage

//JavaScript version
const Sagdb = require("sagdb").default;
//TypeScript version
import Sagdb from "sagdb";
  • Default database name is "db".

  • Db name and folder name is must be String.

  • Database folder name is optional.

  • If you want readable database, set "minify" to false.

const db = new Sagdb({ name: "database", folder: "foldername", minify: true });
const db = new Sagdb({ name: "database", folder: "folder/database" });
const db = new Sagdb({ name: "database" });

Method's

set

  • Set any value with key.
db.set("key", "apple"); // -> apple

Can't set Function.

function test() {}
db.set("key", test); // -> return Error

get

  • Get any value with key.
db.set("key", "apple"); // -> apple

db.get("key"); // -> apple

update

  • Update get a callback function, give old data and return must be a same type old data.
db.update("key", (old_data) => {
  const new_data = old_data.toUpperCase();
  return new_data;
});

delete

  • Delete any key from database.
db.set("key", "apple"); // -> apple

db.delete("key"); // -> apple

db.get("key"); // -> undefined

add

  • Add number to number value.

  • Value must be a Number.

  • Default number is 1.

db.set("number", 1); // -> 1
db.get("number"); // -> 1

db.add("number", 3); // -> 4
db.get("number"); // -> 4

db.add("number"); // -> 5
db.get("number"); // 5

db.add("number", "asd"); // return false

Extra

U can set object in object.

db.set("key.value", "apple"); // -> apple
db.get("key"); // -> { value : "apple" }

Table

import Sagdb, { Table } from "sagdb";

const db = new Sagdb({ name: "database" });

const table = new Table(db, "table_name");

add

table.add(1); // -> {_id: "uuid", data: 1, createdAt: number, updatedAt: number}

find

table.find(callback | data_object); // -> {_id: "uuid", data: 1, createdAt: number, updatedAt: number} | undefined

findById

table.findById("uuid"); // -> {_id: "uuid", data: 1, createdAt: number, updatedAt: number} | undefined

update

table.update(callback | data_object, new_data, force?: boolean); // -> {_id: "uuid", data: 1, createdAt: number, updatedAt: number} | undefined

filter

table.filter(callback | data_object, new_data); // -> old_data:  {_id: "uuid", data: 1, createdAt: number, updatedAt: number}[] | undefined

remove

table.update(callback, all?: boolean); // -> {_id: "uuid", data: 1, createdAt: number, updatedAt: number} | undefined

Listeneer's

On

table.on("event_name", callback()); // -> Listening.

Example

table.on("add", callback(new_data));

table.on("update", callback(old_data, new_data));

table.on("remove", callback(old_data));

License MIT