Socket
Socket
Sign inDemoInstall

mysql-node-query-builder

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysql-node-query-builder

Mysql query builder


Version published
Maintainers
1
Created
Source

Installation

npm install mysql-node-query-builder --save

Usage

BASIC USAGE you need create file "db.json" from root directory. Like this

{
  "host": "localhost",
  "user": "root",
  "password": "secret",
  "database": "mysql"
}
const db = require('mysql-node-query-builder');
db.table('posts')
.where('title', 'like', '%wtf%')
.join('users', 'users.id', '=', 'posts.user_id')
.paginate(15).get().then((posts) => {
    //Do something with posts
}).catch((err) => {
    //handle error
});

Other builder
create(data)
delete(id)
update(data, id)
selectRaw('SELECT * FROM categories as category')
where('id', 5) or where('id', '<>', 5)
whereIn('id', [1,2,3,4,5])
whereNotIn('id', [1,2,3,4,5])
whereRaw('id = 5')
join('categories', 'categories.id', '=', 'posts.category_id')
leftJoin('categories', 'categories.id', '=', 'posts.category_id')
rightJoin('categories', 'categories.id', '=', 'posts.category_id')
count()
orderBy('id', 'DESC');
groupBy('id')
first() return object or bool false
get() return all row of query
Slove n + 1 query problem
ex: db.table('categories').with('horoapps', 'category_id').paginate(5).then((categories) => {
        console.log(categories);
    }));

License

2017 Giang Le.

Keywords

FAQs

Package last updated on 22 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc