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

fasturl.db

v3.0.4

Published

A simple JSON database for javacsript node.js

Downloads

61

Readme

FasturlDB

A simple database that you can use for your projects, supports multiple storage, uses lodash for fast reading and searching, supports nested data storage.

Table of contents

Installing package

Install package using npm i

npm i fasturl.db@latest

Setup database

Import package from node_modules, then add directory path to your database folder

// import { FasturlDB } from "fasturl.db";
const { FasturlDB } = require("fasturl.db");

const db = new FasturlDB({
  directory: "./database",
  showLogs: false
})

This setup will create default database file on path ./database/main/db.json

Create table database

Tables are used to create other storage, you can use the same table to store storage files with the same category or usage.

const { FasturlDB } = require("fasturl.db");

const db = new FasturlDB({
  directory: "./database",
  showLogs: false,
  tables: {
    "account": "/user/accounts.json"
    "user": "/user/users.json"
  }
})

Parameters

| Parameter | Default | Required | Description | | --- | --- | --- | --- | | directory | ./database | false | Defining database paths. | | showLogs | false | false | Showing something logs into your terminal. | | tables | { "main": "/main/db.json" } | false | Used for creating custom database tables. |

With this, all tables will be created automatically by package

Create variables

Actually you don't need this, it's just my need as the author. so this serves to create a default data value when using the get() function instead of returning undefined because the data is not in the object.

// save variables to default table
db.variables({
  "username": "unknown",
  "balance": 0
});

// save variables to custom table
db.variables({
  "username": "unknown",
  "balance": 0
}, "user");

Parameters

| Parameter | Default | Required | Description | | --- | --- | --- | --- | | data | {} | true | Create custom variables data. | | table | main | true | Save variables to default table or custom table. |

You can access this variables using db.Variables or db.Variables.values()

setKey

Used to update the key of a data in the database

db.setKey("user.username", "name") // output: true (if user have data named username)

Parameters

| Parameter | Default | Required | Description | | --- | --- | --- | --- | | oldKey | null | true | oldKey data path | | newKey | null | true | newKey data name | | table | main | false | database table name |

set

Used for save or update data value

// set data to table named account
db.set("totalUser", 999, "account"); // output: 999

// update data user balance
db.set("user.balance", 12000, "user"); // output: 12000

Parameters

| Parameter | Default | Required | Description | | --- | --- | --- | --- | | key | null | true | key data path | | value | null | true | data value | | table | main | false | database table name |

get

Used to get data from database

// get data from table named account
db.get("totalUser", "account"); // output: 999

// get data user balance
db.get("user.balance", "user"); // output: 12000

Parameters

| Parameter | Default | Required | Description | | --- | --- | --- | --- | | key | null | true | key data path | | table | main | false | database table name |

delete

Used to delete data from database

// delete data from table named account
db.delete("totalUser", "account"); // output: true

Parameters

| Parameter | Default | Required | Description | | --- | --- | --- | --- | | key | null | true | key data path | | table | main | false | database table name |

has

Used to check data in database is available or not

// set data to table named account
db.has("totalUser", "account"); // output: false because the data was deleted

Parameters

| Parameter | Default | Required | Description | | --- | --- | --- | --- | | key | null | true | key data path | | table | main | false | database table name |

all

Used to get all data from database

// get all data of table named account
db.all("user"); // output: { ...data }

Parameters

| Parameter | Default | Required | Description | | --- | --- | --- | --- | | table | main | false | database table name |

abbreviate

Used for abbreviating number from long to short

db.abbreviate(12_000_000, "0.00a"); // output: 12.00M

Parameters

| Parameter | Default | Required | Description | | --- | --- | --- | --- | | number | null | true | big number | | format | 0.00a | false | number format output |