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

@decaded/nyadb

v3.0.0

Published

Simple JSON "database" for NodeJS.

Downloads

22

Readme

NyaDB

Simple JSON "database" for NodeJS.

npm (scoped) npm bundle size (scoped) npm GitHub Node.js version


All files will be stored in the NyaDB folder in the project's root directory.


Node.js Version Requirement

This package requires Node.js version 12.x or higher for compatibility with the features and syntax used in the codebase.

Installation

npm install @decaded/nyadb

Usage

Initialize

const NyaDB = require('@decaded/nyadb');
const nyadb = new NyaDB();

You can pass settings on initialization. More information below.

Create new database

nyadb.create('test'); // Creates a new database called 'test'

Inserting data

const mockDatabase = {
	yellow: ['banana', 'citrus'],
	red: ['apple', 'paprika'],
};
nyadb.set('test', mockDatabase); // Sets the database 'test' to the 'mockDatabase' object

Retrieving data

nyadb.get('test'); // Returns the 'test' database

//  {
//    "yellow": ["banana", "citrus"],
//    "red": ["apple", "paprika"],
//  }
nyadb.getList(); // Returns the names of all databases in an array

// ['test']

Deleting data

nyadb.delete('test'); // Deletes the database 'test'

Configuration Settings

You can customize the behavior of the application by modifying the following settings.

| Setting | Default Value | Optional Values | Description | | ----------------- | ------------- | --------------------------------------- | ----------------------------------------------------------------------------------------------------- | | formattingEnabled | true | false | Enable or disable formatting of output. | | formattingStyle | tab | space | Choose between using tabs or spaces for indentation. | | indentSize | 4 | Any non-negative integer | Specify the number of spaces for indentation. Only applicable if formattingStyle is set to "space". | | encoding | utf8 | Any valid encoding supported by Node.js | Specify the encoding for file input/output operations. | | enableConsoleLogs | false | true | Enable or disable logging output to the console. Errors will be logged regardless of this setting. |

Example:

const nyadb = new NyaDB({ formattingStyle: 'space', indentSize: 5 });

Note:

  • Changes to these settings will take effect immediately on initialization.
  • To return to the default values, simply remove the setting.

Migration Guide

Compatibility with previous versions

NyaDB version 3 is fully compatible with databases created using version 2.x. and 1.x. No data migration is required when upgrading to version 3.

⚠ NyaDB version 3 introduces strict procedures for handling configuration settings. If you use them, make sure you pass the correct values ​​listed in the table.

⚠ If you are migrating from 1.x, make sure to update your methods as listed below.

Method Renaming

In version 2.0, some method names were updated for consistency and clarity. Here’s a quick guide on how to update your code:

  • createDatabase() is now create()
  • deleteDatabase() is now delete()
  • setDatabase() is now set()
  • getDatabase() is now get()
  • getDatabaseList() is now getList()

For example, if you previously used nyadb.createDatabase('test'), you should now use nyadb.create('test').

Passing Arguments

Passing arguments on initialization is optional and compatible with version 1.x and 2.x, meaning if you initialized it like this:

const NyaDB = require('@decaded/nyadb');
const nyadb = new NyaDB();

It will still work in version 3.0 the same way as it did before. Just make sure you updated your methods as shown above if you are migrating from version 1.x.

Deprecation Notice

Please note that the previous method names have been deprecated since version 1.5.0 and were removed in 2.0.


Like what I do?