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

havocwebdblite

v0.1.2

Published

Havocweb Tech Mini project DB

Downloads

35

Readme

Contributors npm Version Forks Stargazers

--

Installation

You can install the module using npm or yarn:

NPM:

npm i havocwebdblite

YARN:

yarn add havocwebdblite

Usage

Importing the Module

First, import the HavocwebDB class from the module:

import HavocwebDB from "havocwebdblite"

if you're using a commonJS file you would need to normally require the module.

const HavocwebDB = require('havocwebdblite');

Initializing the Database

To Initialize the database you would have to use the HavocwebDB class from the module.

const Database = new HavocwebDB(databaseName: string, databaseUniqueID: any);

Creating a Table

To create a new table, use the createTable method. Provide the database name, a unique database ID, the table name, and a list of columns.

const createTable = async () => {
    Database.addTable(tableName: string, columnList: Array[]);
};

createTable();

Adding Rows

To add a new row to a table, use the insertIntoTable method. Provide the table name, and the row data (excluding the id, which is generated automatically).

const addRows = async () => {
    Database.insertIntoTable(tableName: string, Row: {});
};

addRows();

Selecting Rows

To select rows from a table based on specific criteria, like mySQL when we want to select a row we use

SELECT column FROM table WHERE key = value

in this case the slect function uses the table name as well and the data and value. use the select(tableName, key, value) method this way. Provide the table name, the key you want to filter by and the value the key is supposed to have.

const selectExample = async () => {
    const selectingRowsWithASpecificValue = await Database.select(tableName: string, key: string, value: string);
    const selectingAllTableRows = await Database.select(tableName: string, "*", "");
    console.log("Specifics", selectingRowsWithASpecificValue, "allDetails", selectingAllTableRows)
};

selectExample();

Deleting Rows

To delete rows from a table based on specific criteria, use the delete function. Provide the table name, and the key and Value.

const deleteExample = async () => {
    Database.delete(tableName: string, key: string, value: string);
    console.log('Row(s) deleted successfully');
};

deleteExample();

Testing

To test the module, you can create a test directory with test files. Here's an example of how to structure your test file to create, add, select, and delete rows assuming you were working on an Express server:

const express = require('express');
const HavocwebDB = require('havocwebdblite');

const router = express.Router();

const Database = new HavocwebDB.HavocwebDB('userTestDatabase', 200100200);

router.post('/createTable', (req, res) => {
    Database.addTable("UserTable", ["email", "name", "password"]);
    res.json({message: "Table created"});
});
router.post('/addUser', (req, res) => {
    const {name, email, password} = req.body;
    Database.insertIntoTable("UserTable", {name, email, password});

    res.json({message: "adding user successful"});
});
router.get("/getAllUsers", async (req, res) => {
    const UserList = await Database.select("UserTable", "*", "");

    res.send(UserList);
});
router.post("/getUser", async (req, res)=>{
    const {email} = req.body;
    const UserList = await Database.select("UserTable", "email", email);

    const narrowedDownUsers = UserList[0];

    res.json({users: UserList, narrowed: narrowedDownUsers});
})
router.post("/deleteRow", async (req, res)=>{
    const {password} = req.body;
    await Database.delete("UserTable", "password", password);
    res.json({message: "account delete successful"});
})
module.exports = router;

Contribution and License Agreement

If you contribute code to this project, you are implicitly allowing your code to be distributed under the MIT license. You are also implicitly verifying that all code is your original work.

License

This project is licensed under the MIT License.