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

demon-jql

v0.0.16

Published

Module which makes using JSON as databases straight-forward.

Downloads

6

Readme

Ever wanted to use JSON as a database in an SQL-Like Environment ? Yeah me neither but still this is a thing..

1.) Installation using NPM

npm install --save demon-jql

2.) Basic Usage

const { Database } = require("demon-jql");
const db = new Database("newDatabase", "./newDatabase"); // Name and Path

3.) Creating a Table

let foodColumns = [
    {
        "type": "text",
        "name": "foodName"
    },
    {
        "type": "text",
        "name": "originCountry"
    }
]

db.createTable("food", foodColumns);

// Expected Return:- bool : true

4.) Inserting Data into Table

let data = [
    {
        "name": "Pizza",
        "originCountry": "Italy",
    },
    {
        "name": "Lahmacun",
        "originCountry": "Turkey"
    }
]

db
.write("food", data)
.run();

// Expected Return:- bool : true

5.) Reading Data from Table.

db
.select("food", "*") // Select Everything
.run();

// Expected Return: Object : { "0": { "name": "Pizza", "originCountry": "Italy" }, "1": { "name": "Lahmacun", "originCountry": "Turkey" }, "success": true }
// The Return object has a property of "success" which is either True/False based on if data was retrieved

db
.select("food", ["name"]) // If Selecting Columns Specifically, They need to be placed in a StringArray[] (even for individual columns) e.g ["name", "originCountry"]
.where({"originCountry": "Turkey"}) // Where Method takes in a Object as parameter.
.run();

// Expected Return:- Object : { "0" : {"name": "Pizza" }, "success": true }

6.) Updating Pre-existing Data.

// Warning: Using .update() without .where() will Update the entire table.

db
.update("food", {"name": "Kebab"}) // Update method takes in the Table name and Object as parameters.
.where({"originCountry": "Turkey"})
.run();

// Expected Return:- bool : true

7.) Using Auto Increments


db.createTable("users", [
    {
        "type": "number",
        "name": "id"
    },
    {
        "type": "text",
        "name": "username"
    }
])

// Expected Return:- bool : true

// If writing a Single row, It still needs to be placed inside an Array[]
db.write("users", [
    {
        "id": db.nextID(),
        "name": "Demonicious"
    }
]).run();

// Expected Return:- bool : true

8.) An Example

const { Database } = require("demon-jql");
const db = new Database("db2", "./db2");

// Creating a New Table
// .run() method isn't used here.
db.createTable("someTable", [
    {
        "type": "number",
        "name": "id"
    },
    {
        "type": "text",
        "name": "name"
    }
]);

// Filling the table with Data
db.write("someTable", [
    {
        "id": db.nextID(),
        "name": "Demonicious1"
    },
    {
        "id": db.nextID(),
        "name": "Demonicious2"
    },
    {
        "id": db.nextID(),
        "name": "Demonicious3"
    },
    {
        "id": db.nextID(),
        "name": "Demonicious4"
    },
    {
        "id": db.nextID(),
        "name": "Demonicious5"
    },
    {
        "id": db.nextID(),
        "name": "Demonicious6"
    }
]).run();

// Updating a Row
// .where() is optional but without it, it will rewwrite the entire table.
db.update("someTable", {
    "name": "DemoniciousSIX"
}).where({
    "id": "5"
}).run();

// Removing a Row
db.removeRow("someTable").where({
    "id":"4"
}).run();

// Retrieving single column
// .where() is optional in Select
var data = db.select("someTable", [
    "name"
]).where({
    "id": "5"
}).run();

if (data.success) {
    console.log("Name Fetched From Table:", data[0]["name"]);
}

// Retrieving Multiple Columns
data = db.select("someTable", [
    "id",
    "name"
]).where({
    "id": "5"
}).run();

if (data.success) {
    console.log(data);
}

// Retrieving Everything
var data = db.select("someTable", "*").where({
    "id": "5"
}).run();

if (data.success) {
    console.log(data);
}

// Removing a Table Entirely
// .run() isn't used here.
// I removed this table just to show it can be done.
db.removeTable("someTable");

// Just a simple test method()
db.test()
// Returns True if DB is working, otherwise False

I plan to Make a lot of Optimizations and add more features (making it more sql-like)