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

sags.db.ts

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sags.db.ts

Fast JSON database system.

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

SagsDbTs

Image Image

Image

Sags.db.ts is JSON database system.

Installation

npm install sags.db.ts

Usage

const sagsdb = require("sags.db.ts");

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"); // -> db

Can't set Function.

function test(){

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



Get

Key must be a String or Number.

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

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



Delete

Delete item from database.

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

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

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"); // -> db
db.has("key"); // -> true

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



Push

Push item in Array.

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

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



Unpush

Unpush item from Array.

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

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



Add

Add number to number value.

Value must be a Number.

Default number is 1.

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

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

db.add("number"); // -> db
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); // -> db
db.get("number"); // -> 1

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

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

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



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"); // -> db
db.get("key"); // -> apple
db.deleteAll(); // -> true
db.get("key"); // -> undefined



Dbsize

Get database size.

Number type is Byte (byte).

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

Extra

U can set object in object.

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

License

MIT

Keywords

FAQs

Package last updated on 04 Oct 2022

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