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

boiler-mysql

v1.0.2

Published

This a simple package to help developers to execute CRUD operation using NodeJs for SQL databases.

Downloads

7

Readme

This is a simple Node.js package for performing SQL CRUD operations, supported by Codebaz.

Getting started

First, install the package running the following command:

npm install boiler-mysql

Then, go to .env file or create it if you don't have it and set this variables:


DB_HOST='localhost'
DB_PORT=3306
DB_DATABASE='<database_name>'
DB_USER='<database_user>' # usually its root
DB_PASSWORD='<database_password>'

This package has the following functions: Create, Select, Update and Delete.

First, you have to import the function:

import { Create, Select, Update, Delete } from 'sql-crud'

1. Create

You can use the Create function to insert data into some table on database.

Basic usage To create new record you just need two parameters: the tableName whitch must have the name of your table name and the values whitch is a object that contains the data to store.

Example: Lets insert random data to users table


const newData = async () => {
    const insertData = await Create({
        tableName: 'users',
        values: { firstName: 'john', lastName: 'Doe', email: '[email protected]' }
    });

    return insertData; # it will return an object
}

The response object have the following structure:


    {
        status: 200 || 404 || 500 ||,
        message: 'message according to the status of your request',
        data: [] || null # if the status is 200 it will return the data inserted
    }

2. Select

The basic usage of Select function is to display data from database

Example 1:


const selectData = async () => {
    const promise = await Select({
        tableName: 'users'
    })

    return promise;
}

The Select function have follwing parameters:

| Parameter | Description | |-----------------------|----------------------------------| | tableName | The name of the table | | columns | specify the columns you want to select. It comes into array. Example: ['firstName', 'email'] | | where | specify where to select. example: [ email: '[email protected]' ] | | include | include related tables | | join | it will join tables. | | take | specify the number of rows to retrieve. By default is 12 rows | | orderBy | specify the order. It must be an array whitch the key is the column and the value of that key is the type of order. Example: [ createdAt: 'desc' ] |

Example 2:


const selectData = asycn () => {
    const data = await Select({
        tableName: 'product',
        where: [userId: '312'],
        include: ['users'],
        join: ['category'],
        take: 5,
        orderBy: [id: 'desc']
    });

    return data;
}

You can check out the sql-crud GitHub repository - your feedback and contributions are welcome!