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

dirfile-db

v0.0.1

Published

A directory/file based data storage project

Downloads

3

Readme

DirfileDB

DirfileDB is a file system based data store. Currently built as a NoSQL style JSON store, it defines a new database as a directory, collections as a sub-directory and documents as files. It can be used as a quick local testing database, or in low user/throughput applications. Originally built for local first/offline capable single user applications.

It aims to maintain zero dependencies (outside of devDependencies), using only NodeJs functionality.

It is very much still in early development and subject to large breaking changes.

Table of Contents

Installation

  1. Clone the repository

    git clone https://github.com/nathanbbarton/dirfile-db.git
    
    cd dirfile-db
  2. Install dependencies

    npm install

Usage

Using your first DirfileDB

import DirfileDB from "dirfile-db"

const newDB = DirfileDB({rootDir: myNewDB})

await newDB.init() //directory structure is not created until init is run

After a DirfileDB has been setup with init() you can create new collections and add new documents.

Creating a new Collection

await newDB.newCollection("firstCollection")

Creating a new Document

await newDB.create("firstCollection", { key: "value" })

DirfileDB has a universal expectation of an _id key value pair, and if a new document is provided without one it will create append and id to the document.

Find a Document

find() is a "find first instance" function meaning, given the provided query returns the first instance of a document that matches the query

newDB.find("firstCollection", { key: "value" })

to find by id simply pass the id as the query

newDB.find("firstCollection", { _id: "someId" })

Find multiple Documents

findAll() will return all documents that match a query.

Same as find,

newDB.findAll("firstCollection", { key: "value" })

A full set of documentation will be published as the project stabilizes from early development

Building the Project

Currently esbuild is used to bundle a cjs and esm version.

To build the project, run:

npm run build

Running Tests

Currently testing is done using jest, feelings toward this are unstable and may change.

To run tests, run:

npm test

Additional Scripts

//Compiles typescript types
"build:types": "tsc --project configs/tsconfig.types.json",

//Runs the esbuild script to bundle the module
"esbuild": "node ./scripts/build.js",

// Runs eslint, config found under ./configs
"lint": "eslint src/**/*.ts --config configs/.eslintrc.json --format stylish",

//Attempts to fix any fixable linting warnings/errors
"lint:fix": "eslint src/**/*.ts --format stylish --fix",

//Helper script that cleans up build directory and default DBs that are made during development
"clean": "npm-run-all clean:dist clean:dbs",

//Removes the build directory
"clean:dist": "rimraf dist",

//Removes commonly made DBs during development
"clean:dbs": "rimraf defaultDB testDB",

//Full package reinstallation
"reinstall": "rimraf node_modules && npm install",

//Cleans and Reinstalls for a full development reset
"reset": "npm-run-all clean reinstall"

Configuration

Current configuration is limited to naming the directory of your database.


const config = {
    rootDir: "CustomDB"
}

const newDB = DirfileDB(config)

If no rootDir is provided your database will default to "defaultDB"

Contributing

Contributions are welcome! Please follow these steps to contribute:

Fork the repository.
Create a new branch (git checkout -b feature/your-feature).
Make your changes.
Commit your changes (git commit -m 'Add some feature').
Push to the branch (git push origin feature/your-feature).
Open a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.