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

sags.db

v1.2.7

Published

Fast JSON database system.

Downloads

37

Readme

sagsDB

Image Image

Image

Sags.db is JSON database system.

Installation

npm install sags.db

Usage

const sagsdb = require("sags");

Default database name is "db".

Db name and folder name is must be String.

Database folder name is optional.

If u dont wanna minify set "minify" to false.

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

or

const db = new sagsdb({ name: "database", folder: "folder/database"});

or

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

You can create multi database.

const userdb = new sagsdb({ name: "userdb"});
const itemdb = new sagsdb({ name: "itemdb"});

COMMANDS

Set

Key must be a String or Number.

db.set("key", "apple"); // -> true

Can't set Function.

function test(){

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

Get

Key must be a String or Number.

db.set("key", "apple"); // -> true

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

Delete

Delete item from database.

db.set("key", "apple"); // -> true

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

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

Type

Check type for this key.

db.set("key", "apple");
db.type("key"); // -> string

db.set("array", [1, 2, 3]);
db.type("array"); // -> array

db.set("object", { a: 1, b: 2 }); // -> true
db.type("object"); // -> object

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

Has

Check database for this key.

db.set("key", "apple"); // -> true
db.has("key"); // -> true

db.has("another"); // -> false

Push

Push item in Array.

db.push("array", "apple"); // -> true
db.get("array"); // -> ["apple"]

db.push("array","banana"); // -> true
db.get("array"); // -> ["apple", "banana"]

Unpush

Unpush item from Array.

db.push("array", "apple"); // -> true
db.get("array"); // -> ["apple"]

db.unpush("array", "apple"); // -> true
db.get("array"); // -> []

Add

Add number to number value.

Value must be a Number.

Default number is 1.

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

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

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

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

Subtract

Subtract number to number value.

Value must be a Number.

Default number is 1.

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

db.subtract("number", 3); // -> true
db.get("number"); // -> -2

db.subtract("number"); // -> true
db.get("number"); // -3

db.subtract("number", "asd"); // return Error

Head

Get value first item.

db.set("string", "str"); // -> true
db.head("string"); // -> "s"

db.set("number", 321); // -> true
db.head("number"); // -> 3

db.set("array", [1, 2, 3]); // -> true
db.head("array"); // -> 1

db.set("object", {a : 1, b: 2}); // -> true
db.head("object"); // -> 1

Tail

Get value last item.

db.set("string", "str"); // -> true
db.tail("string"); // -> "r"

db.set("number", 321); // -> true
db.tail("number"); // -> 1

db.set("array", [1, 2, 3]); // -> true
db.tail("array"); // -> 3

db.set("object", {a : 1, b: 2}); // -> true
db.tail("object"); // -> 2

Nth

Get value with index.

db.set("string", "str"); // -> true
db.nth("string", 1); // -> "t"

db.set("number", 321); // -> true
db.nth("number", 1); // -> 2

db.set("array", [1, 2, 3]); // -> true
db.nth("array", 1); // -> 2

db.set("object", {a : 1, b: 2}); // -> true
db.nth("object", 1); // -> 2

All

Return all Database object.

db.set("key", "apple");
db.set("number", 1);
db.all(); // -> {"key" : "apple", "number": 1}

DeleteAll

Delete all database.

db.set("key", "apple"); // -> true
db.get("key"); // -> apple
db.deleteAll(); // -> true
db.get("key"); // -> undefined

Dbsize

Get database size.

Number type is kilobyte (kb).

db.set("key", "apple"); // -> true
db.dbSize(); // -> 15

Extra

U can set object in object.

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

License

MIT