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

acar.db

v1.0.1

Published

It is a nice module that you can easily generate and update your data via MySQL.

Downloads

3

Readme

AcarDB

Acar.db is an open-source package meant to provide an easy way for beginners and people of all levels to access & store data in a low to medium volume environment. All data is stored persistently via either promise-mysql and comes way various other quality-of-life features.

It is a nice module that you can easily generate and update your data via MySQL. Persistent Storage - Data doesn't disappear through restarts Multiple Drivers - You can use either promise-mysql Works out of the box - No need to set up a database server, all the data is stored locally in the same project

Installation

npm i acar.db promise-mysql    # MySQL Server Connection

Example

const { AcarDB, MySQLDriver } = require("acar.db");
(async () => {
    const mysqlDriver = new MySQLDriver({
        host: "localhost",
        user: "root",
        password: "",
        database: "database",
    });

    await mysqlDriver.connect(); 
    const db = new AcarDB({ driver: mysqlDriver });
    await db.set("array", [
        "acar",
        "sehira",
        "kedy",
        "lamer"
    ]);
    let data = await db.get("array") || []
    data.filter(x => x != "lamer").map(x => x).join(", ")
    // -> ['acar','sehira', 'kedy']
})();

Example

(async () => {
    // self calling async function just to get async
    // Setting an object in the database:
    await db.set("guild", { id: 1 });
    // -> { id: 1 }

    // Getting an object from the database:
    await db.get("guild");
    // -> { id: 1 }

    // Getting an object property from the database:
    await db.get("guild.id");
    // -> 1

    // Setting an object in the database:
    await db.set("guild", { id: 2 });
    // -> { id: 2 }

    // Pushing an element to an array (that doesn't exist yet) in an object:
    await db.push("guild.members", "acar");
    // -> { id: 2, members: ['acar'] }

    // Adding to a number (that doesn't exist yet) in an object:
    await db.add("guild.level", 1);
    // -> { id: 2, members: ['acar'], level: 1 }

    // Repeating previous examples:
    await db.push("guild.members", "sehira");
    // -> { id: 2, members: ['acar', 'sehira'], level: 1 }
    await db.sub("guild.level", 500);
    // -> { id: 2, members: ['acar', 'sehira'], level: 501 }

    // Fetching individual properties
    await db.get("guild.id"); // -> 2
    await db.get("guild.level"); // -> 501
    await db.get("guild.members"); // ['acar', 'sehira']
})();

pull()

await db.set("members", [
    "acar",
    "kedy",
    "sehira",
    "chavo"
]);

await db.pull("members", "chavo"); // Removing a single item
// -> ['acar', 'kedy', 'sehira']

await db.pull("members", ["kedy", "sehira"]); // Removing multiple options
// -> ['acar']

await db.pull("members", (i) => i.includes("chavo")); // Using a function
// -> []

Table

// optional Async add await
let nTable = db.table("new_table");