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

litejsondb

v1.0.4

Published

LiteJsonDB is a lightweight, local JSON database for Node.js. It provides a simple and intuitive API for managing JSON data. This package is a fork of the Python LiteJsonDB project, adapted for Node.js, and is currently about 45% complete.

Downloads

6

Readme

📚 LiteJsonDB Documentation

LiteJsonDB is a lightweight local JSON database for Node.js, designed to simplify JSON data management in your projects. This package is a fork of the Python LiteJsonDB project, adapted for Node.js. Currently, this project is about 45% complete, meaning it's already super functional but still has room for more cool features.

LiteJsonDB is like a nifty little vault for your JSON data. It provides a simple and intuitive API for adding, modifying, retrieving, and deleting data. You don't need to worry about the complexities of heavier database systems. With LiteJsonDB, you can focus on what really matters: your data.

🔧 Installation

To get started with LiteJsonDB, you need to install it via npm. It's super easy! Just run the following command in your terminal:

🎯 Usage

🏁 Initialization

Once installed, you can import LiteJsonDB and initialize your database like this:

📥 Adding Data

Adding data is a breeze with LiteJsonDB. Use the setData method to store information in the database:

🔄 Editing Data

To update existing data, use editData. You can modify information without erasing what’s already there:

📜 Getting Data

The getData method allows you to retrieve data from the database. You can specify the exact path of the data you want to access. Here’s how you can use it:

Explanation:

  • Path Specification: You use a key path like 'users/1' or 'products/1' to retrieve specific entries from the database. The key path is a string that denotes the location of the data in the hierarchical structure of the database.
  • Default Behavior: If the specified path does not exist, getData may return undefined. Ensure you handle such cases in your code to avoid errors.

❌ Deleting Data

Need to delete data? No problem! The deleteData method allows you to remove specific information. You have two options:

  1. Delete Specific Entry: If you want to delete a specific entry, provide the exact key path:

    This command will remove only the data located at 'products/1', leaving other data intact.

  2. Delete All Data Under a Path: If you want to delete all data under a specific key path, you can use a nested key path:

    This will remove the entire 'products' section, including all entries within it, such as 'products/1' and any other nested products.

Explanation:

  • Specific Entry Deletion: By providing a precise path like 'products/1', you delete only that particular entry.
  • Path-Wide Deletion: Using a broader path like 'products' deletes everything under that path. This is useful for clearing out all related data but should be used carefully to avoid unintentional data loss.

🔍 Searching Data

You can also search your data with searchData. This helps you find specific values anywhere in the database:

🛠️ Utility Functions

LiteJsonDB includes some handy utility functions:

  • hashPassword(password): Hashes the given password.
  • checkPassword(storedHash, password): Checks if the password matches the stored hash.
  • getOrDefault(data, key, defaultValue): Returns the value for the key or a default value if the key doesn’t exist.
  • keyExistsOrAdd(data, key, defaultValue): Checks if the key exists and adds it with a default value if not.

Here’s how you can use them:

📖 Example Code

Here’s a small example to show you how everything works together:

🛠️ Future Development

LiteJsonDB is a fork of our Python LiteJsonDB package. I’ve managed to reproduce about 45% of the work so far, and it's already functional with features like adding, editing, and deleting data. However, there’s still a lot to be done!

If you have skills in both Node.js and Python, you might want to dive into the code and contribute to the Node.js project. Currently, I’m focused more on Python development and may not have enough time to add all the desired features to this package.

Your contributions could help move the project forward and make it even better. Feel free to explore the code and get involved!

💬 Contribution

If you want to contribute to the project, feel free to open issues or pull requests. Every contribution is welcome to help make this project even better!