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 🙏

© 2026 – Pkg Stats / Ryan Hefner

mysql-builder-plus

v0.2.1

Published

A auto-builder for mysql statement

Readme

mysql-builder-plus

INSTALL

npm i mysql-builder-plus

USAGE

This package can build sql statement simply by json, and can set conditions by chain, and supports different databases.

The example is in example.js, or you can straightly browse the following.

can use different databases for different sqlClasses using different configs

let sqlClass = require("./index");

default: ./connect.json

sqlClass.setConfigPath("./connect.json");

insert

let sqlInsert = sqlClass.form("archives", {
  name: "testName",
  description: "testDescription",
  tags: "{}",
  series_id: 0,
  series_order: 0,
  filepath: "testFilepath",
  create_time: "2020-10-3 18:55:13",
});

also like this

let sqlInsert = sqlClass.form();
sqlInsert.setTable("archives");
sqlInsert.setData({
    name: "testName",
    description: "testDescription",
    tags: "{}",
    series_id: 0,
    series_order: 0,
    filepath: "testFilepath",
    create_time: "2020-10-3 18:55:13",
});

to insert

sqlInsert.insert((error) => {
  if (error) {
    console.log(error);
  } else {
    console.log("insert success");
  }
});

select

plus conditions

sqlSelect.where("name", "nAme").where("id", 7, ">").where("name", "%114514%", "LIKE", "or");

//if need more complex logical relation, can also use this
// sqlSelect.whereSetByStr("name NOT LIKE '%name%' AND (id < 7  OR id = 14)");

//if true, check the case (default: true)
sqlSelect.setBinary(true);

//change the order returned from mysql
sqlSelect.orderBy("id", "desc");

//limit the num returned from mysql
sqlSelect.limit(2);

//check the sql statement(auto-check in insert/delete/update/select)
let err = null;
if(err = sqlSelect.examine()){
    console.log(err);
}

to select

sqlSelect.select((error, data) => {
    if(error) {
        console.log(error);
    } else {
        console.log(data);
    }
});

update

let sqlUpdate = sqlClass.form("archives");

//conditions are also like select
sqlUpdate.where("id", 6);

//data is also like insert
sqlUpdate.setData({
    name: "testName",
    description: "testDescription",
    tags: "{}",
    series_id: 0,
    series_order: 0,
    filepath: "testFilepath",
    create_time: "2020-10-3 18:55:13",
});

to update

sqlUpdate.update((err) => {
    if(err) console.log(err);
    else console.log("update success");
});

delete

let sqlDelete = sqlClass.form("archives");
//conditions are also like select
sqlDelete.where("id", 5);

to delete

sqlDelete.delete((err) => {
    if(err) console.log(err);
    else console.log("delete success");
});

ABOUT ME

I'm just a green hand in node, writing this for try. If you have some advice or find some bug in this package, welcome to contact me, thanks a lot!