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

folderbase

v1.5.0

Published

Folderbase is a folder based database for NodeJS!

Downloads

2

Readme

Folderbase

Folderbase is a folder based database for NodeJS!

This is a nosql, easy to setup database in which you just need to install folderbase and start using it!

Installation

To install folderbase, just run the following command:-

Latest version

npm i folderbase@latest

OR

yarn add folderbase@latest

Specific version

npm i folderbase@<version>

OR

yarn add folderbase@<version>

Note: Remember to replace <version> with your version, for example 1.0.0!

Docs

In folderbase, database are called folders, tables are called files, rows are called objects and columns are called fields!

Importing the module

To import and use this module, you need to define your nodejs project as a module, you can simply do this by adding a field in your package.json file:-

{
  "type": "module"
}

This package only exports a class named as Folder which helps in all of the database and table related operations!

import Folder from '@alphasoftx/folderbase';

Creating a new folder (database)

To create a new folder in folderbase, you can use Folder class by the following method:-

// Creating a database with name 'todo-app'
let todoApp = new Folder('todo-app');

This will create a new folder in your project with name todo-app where the data of this database will be saved!

If the folder already exists, and it contains files, the files will be added to todoApp.files!

If tou have multiple databases and you want to create your all databases in a particular folder, you can use the following method:-

// Creating 'todo-app' in a folder named 'databases'
let todoApp = new Folder('todo-app','databases');

Removing a folder:-

To remove a folder, you can easily use the following code:-

// Removing a folder named 'todo-app'
todoApp.remove();

This will remove the folder todo-app!

Note: The variable todoApp should not be used after removal of the folder 'todo-app'!

Adding a new file (table)

To add a new file in folderbase, run the following code:-

// Adding a file 'users' in 'todo-app' folder
todoApp.addFile('users');
// File will be saved in todoApp.files.users

This will create a users.json in todo-app folder where the data of users file will be saved!

Removing a file

To remove a file, use following code:-

// Removing a file 'users' from 'todo-app' folder
todoApp.removeFile('users');

This will remove the users.json file!

Working with files

Adding data

To add data in you table, you can use add query:-

todoApp.files.users.add({
  name: 'Raju',
  username: 'RajeshSharma',
  password: 'Rajesh31012013'
});
// This will add this user to 'users' file,
// with an extra field '_id' which contains a unique id of that field!

Note: Don't add '_id' field in your object while adding, because it will be overwritten to a unique id!

Retrieving data

To get data from the file, you can use find query:-

// To get all the entries
todoApp.files.users.find({});

// To get filtered data
// Returns all entries with username 'RajeshSharma'
todoApp.files.users.find({ username: 'RajeshSharma' });

// Filters strings by Regular expressions
// Returns all entries which contains 'Rajesh' in username
todoApp.files.users.find({ username: /Rajesh/ });

// Filter entries case insensitively
// Return all entries with username 'RajeshSharma' case insensitively
todoApp.files.users.find({ username: /^RajeshSharma$/i });

Updating data

To update data, you can use update query:-

// First parameter: find query obj,
// Second parameter: obj with fields to update
// Third parameter: replace (boolean), default value is false

// Updates the password field of object
todoApp.files.users.update({
  username: 'Aditya'
},{
  password: 'Adi18012008'
});

// Replace the whole user except _id field
todoApp.files.users.update({
  username: 'Aditya'
},{
  name: 'Aditya Verma',
  username: 'AdityaVerma',
  password: 'Adi18012008'
}, /* replace */ true);

Removing data

To remove data from files, you can use remove query:-

// Removes all fields with name 'Abhishek'
todoApp.files.users.remove({
  name: 'Abhishek'
});

Hope this was helpful for you!