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

fuming

v1.0.1

Published

Fuming is a lightweight and efficient database management system built with TypeScript. It simplifies database operations with type safety, robust query handling, and seamless integration into any modern web application. Fuming is designed as an npm packa

Downloads

122

Readme

Fuming Database

npm version TypeScript License: GPL v3

Fuming is a lightweight and efficient database management system built with TypeScript. It simplifies database operations with type safety, robust query handling, and seamless integration into any modern web application.

Features

  • 🚀 Lightweight & Fast: Minimal overhead with efficient file-based storage
  • 📘 TypeScript Support: Full type safety and excellent IDE integration
  • 🔄 CRUD Operations: Complete set of Create, Read, Update, and Delete operations
  • 🛠️ Easy Setup: Simple installation and minimal configuration
  • 📁 Collection-based: Organize your data in collections, similar to MongoDB
  • 🆔 Automatic ID Generation: Built-in unique ID generation for documents

Installation

npm install fuming

Quick Start

import { connect, collection } from 'fuming';

// Connect to database
const db = await connect('mydb');

// Create a collection
collection.create('users');

// Insert data
await collection.insert('users', {
  name: 'John Doe',
  email: '[email protected]',
  age: 30
});

// Find all documents
const users = collection.find('users');
console.log(users);

API Reference

Connection

connect(dbname: string): Promise<string[]>

Connects to a database. Creates the database directory if it doesn't exist.

const collections = await connect('mydb');
// Returns array of existing collection names

Collections

collection.create(collection: string)

Creates a new collection.

collection.create('users');

collection.find(collection: string)

Retrieves all documents from a collection.

const users = collection.find('users');

collection.insert(collection: string, newData: any)

Inserts a new document into a collection. Automatically generates a unique _id.

await collection.insert('users', {
  name: 'Jane Doe',
  email: '[email protected]'
});

collection.update(collection: string, { key, value }, newData)

Updates a document in a collection based on a key-value pair.

await collection.update('users', 
  { key: 'email', value: '[email protected]' },
  {
    name: 'John Smith',
    email: '[email protected]'
  }
);

collection.remove(collection: string, { key, value })

Removes a document from a collection based on a key-value pair.

await collection.remove('users', {
  key: 'email',
  value: '[email protected]'
});

collection.destroy(collection: string)

Deletes an entire collection.

await collection.destroy('users');

Data Structure

Each document in a collection automatically receives a unique _id field when inserted:

{
  "_id": "lqr1k3j4x9ab2m5n",
  "name": "John Doe",
  "email": "[email protected]"
}

Example Usage

Creating a User Management System

import { connect, collection } from 'fuming';

async function initializeDatabase() {
  // Connect to database
  await connect('userdb');
  
  // Create users collection
  collection.create('users');
}

async function addUser(userData: any) {
  return await collection.insert('users', userData);
}

async function updateUserEmail(oldEmail: string, newData: any) {
  return await collection.update('users', 
    { key: 'email', value: oldEmail },
    newData
  );
}

async function deleteUser(email: string) {
  return await collection.remove('users', {
    key: 'email',
    value: email
  });
}

// Usage
initializeDatabase()
  .then(() => addUser({
    name: 'John Doe',
    email: '[email protected]',
    role: 'admin'
  }))
  .catch(console.error);

Notes

  • All collection operations are file-based and synchronous
  • Data is stored in JSON format
  • Each database is a directory containing JSON files for each collection
  • The database name is stored in the environment variables
  • Collection names map directly to JSON files

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. By contributing to this project, you agree to abide by its terms.

License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.

GNU GPL v3

Fuming is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.