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

big-fsdb

v1.0.5

Published

__fsdb__ stands for `File System as a DataBase.`

Downloads

26

Readme

simple-fsdb

fsdb stands for File System as a DataBase.

It uses your local disk as a database. big-fsdb is designed to be used for large databases. Unlike simple-fsdb, it does not parse the whole database, instead splitting it into chunks and clusters to process, leading to less process time, less disk read/write cycles, and faster response time.

How to use:

Installing

In your project terminal, run

npm install big-fsdb

Then, at the beginning of your main js file, require it.

const fsdb = require("big-fsdb")

Setting up a database

let db = new fsdb(path, init, clustersize)
  • path:
    • Accepts: string
    • Serves as the identifier of the db. Also, the db file is saved at the path
    • Ex. myFirstDatabase will lead to the db being stored at myFirstDatabase.json
  • init (optional, defaults to {}):
    • Accepts: object
    • If no such database file exists, one will be created, with the contents of init
    • Ex, {bar:"foo", number:5} will lead to the database being created with bar=foo and number=5
  • clustersize
    • Accepts: integer
    • Number of JSON key/value pairs per file. Smaller number leads to more JSON files, but faster and less compute time.
    • Defaults to 100
  • Multiple databases can be set up this way. Make sure not to use the same path or variable name twice.

Setting values

Setting a key to a value in the database

db.set(key, value)
  • key
    • Accepts: string
    • Acts as the key in the key/pair value.
  • value
    • Accepts:string, number, object, array
    • Value to link to the key
  • Ex.
db.set("numberOfCars", 5)

Reading values

Retrieves a value from the database, using the key.

db.get(key)
  • key
    • Accepts: string
    • Acts as the key in the key/pair value.
  • Returns
    • Value that links to the key. If not found, returns undefined
  • Ex.
db.get("numberOfCars")

Deleting values

Deletes a key/value pair from the database.

db.delete(key)
  • key
    • Accepts: string
    • Acts as the key in the key/pair value.
  • Deletes the key/pair value
  • Ex.
db.delete("numberOfCars")

Prefix

Filter through all data in the dataabase using a prefix

db.prefix(pre)
  • pre
    • Accepts: string
    • The prefix to look for
  • Returns
    • All the key/value pairs where the key starts with pre, in a js object

Examples:

let fsdb = require("big-fsdb")
let db =new fsdb("db1", {hello:"hi"})
//If db1/ does not exist, one will be created with data {hello:"hi"}
db.set("cars", 4)
console.log(db.get("cars"))
// logs 4
db.set("car1", "1999 old car")
console.log(db.prefix("car"))
// logs {cars:4, car1:"1999 old car"}
db.delete("cars")
db.set("cereal", "frosted flakes")