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

magmadb

v1.3.3

Published

Magmadb, a user-friendly solution for storing and accessing data.

Downloads

28

Readme

Magmadb is a package that offers a user-friendly solution for storing and accessing data in a low to medium volume environment, suitable for individuals with varying levels of expertise. The data is stored locally and persistently in json format, and the package also provides a variety of convenient features to enhance the user experience.

A MAJOR BUG HAS BEEN FIXED, MAGMADB NOW WORKS PERFECTLY!

  • Persistent Storage - Data doesn't disappear through restarts
  • Works out of the box - No need to set up a database server, all the data is stored locally in the same project
  • Beginner Friendly - Originally created for use in tutorials or in small projects
  • & more...

Installation

npm i magmadb
//Importing Magmadb
const MagmaDatabase = require("magmadb");

//Create a new database named "db1"
const db = new MagmaDatabase("db1");
//Create a new collection named "accounts" inside "db1" to store user account data 
const accounts = db.CreateCollection("accounts");

//Now we want to create a user account
//Create a new data document inside the collection "accounts"
accounts.CreateData({
    id: 38437838728397,
    name: "Jacob",
    email: "[email protected]",
    password: "password123"
});

//Now for looking up a user inside a collection
//Find a document inside "accounts" by its id
const jacob = accounts.GetData({ id: 38437838728397 });
console.log(jacob);
/*
This will return the following object:
{
    id: 38437838728397,
    name: "Jacob",
    email: "[email protected]",
    password: "password123"
}
*/

//Now Jacob wants to change his email from to "[email protected]"
//First we get Jacob's account to update his email
const jacob = accounts.GetData({ id: 38437838728397 });
//Then we call the function Collection.UpdateData() to make changes to Jacob's account
//Our Collection here is "accounts" so:
accounts.UpdateData(jacob, {
    email: "[email protected]"
});
console.log(jacob);
/*
This will return the following object:
{
    id: 38437838728397,
    name: "Jacob",
    email: "[email protected]",
    password: "password123"
}
As you can see Jacob's email has been changed from "[email protected]" to "[email protected]"
*/

//Lets create another account so we can have multiple documents inside our collection
accounts.CreateData({
    id: 49845168798135,
    name: "Walter",
    email: "[email protected]",
    password: "password123"
});

//You can also get all documents in a collection using Collection.GetAllData();
const allAccounts = accounts.GetAllData();
console.log(allAccounts);
/*
This will return the following Array of documents:
[
    {
        id: 38437838728397,
        name: "Jacob",
        email: "[email protected]",
        password: "password123"
    },
    {
        id: 49845168798135,
        name: "Walter",
        email: "[email protected]",
        password: "password123"
    }
]
*/

//Lets try finding all users with the password "password123"
let usersWithSamePassword = accounts.Find({ password: "password123" });
console.log(usersWithSamePassword);
/*
This will return the following Array of documents:
[
    {
        id: 38437838728397,
        name: "Jacob",
        email: "[email protected]",
        password: "password123"
    },
    {
        id: 49845168798135,
        name: "Walter",
        email: "[email protected]",
        password: "password123"
    }
]
Because Jacob and Walter has the same password ("password123")
*/

//Jacob wants to get his account deleted! Let's make his wish true.
//Lets get Jacobs account by his id
const jacob = accounts.GetData({ id: 38437838728397 });
accounts.DeleteData(jacob) //Here called Collection.DeleteData(jacob) to delete Jacob's account from the database.
//Now we check if Jacob's account is deleted by console logging all accounts
console.log(accounts.GetAllData());
/*
This will return the following Array of documents:
[
    {
        id: 49845168798135,
        name: "Walter",
        email: "[email protected]",
        password: "password123"
    }
]
//Jacob is out!
*/

//If you want to delete the whole accounts collection from your database use Database.DeleteCollection(collection)
//in our case here, Database is "db" and Collection is "accounts"
db.DeleteCollection(accounts);
//lets try console logging "accounts" after deleting it
console.log(accounts.GetAllData()); //This will return undefined