GithubHelp home page GithubHelp logo

00mjk / queryizejs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from twipped/queryizejs

0.0 0.0 0.0 447 KB

A no-frills chainable interface for constructing MySQL queries for node.js

Home Page: http://queryizejs.com

License: MIT License

JavaScript 100.00%

queryizejs's Introduction

#queryize.js

A no-frills chainable/fluent interface for constructing mutable MySQL queries with data binding/escapement.

NPM version Licensed MIT Nodejs 8+ Downloads Build Status

##Installation

NPM: npm install queryize

##Usage

In Node or another CommonJS environment:

var queryize = require('queryize');
var query = queryize().select();
var select = require('queryize').select;
var query = select();

Visit queryizejs.com for documentation.

##Examples

var select = require('queryize').select;
var q = select()
    .from('users', 'u')
    .innerJoin('passwords', {alias: 'p', on: {'u.id':'p.user_id'}})
    .where({'u.email': '[email protected]'})
    .columns('u.id', 'p.hash')
    .compile();

//q.query contains SELECT u.id, p.hash FROM users u INNER JOIN passwords p ON (u.id = p.user_id) WHERE u.email = ?
//q.data contains  ['[email protected]']
var queryize = require('queryize');
var q = queryize()
    .insert().into('users')
    .set({name: 'John Doe', email: '[email protected]'})
    .compile();

//q.query contains INSERT INTO users SET u.name = ?, u.email = ?
//q.data contains  ['John Doe', '[email protected]']
var queryize = require('queryize');
var q = queryize()
    .update().table('users')
    .set({name: 'John Doe', email: '[email protected]'})
    .where({'u.id':1})
    .compile();

//q.query contains UPDATE users SET u.name = ?, u.email = ? WHERE u.id = ?
//q.data contains  ['John Doe', '[email protected]', 1]
var queryize = require('queryize');
var q = queryize()
    .deleteFrom('users')
    .where({'u.id':1})
    .compile();

//q.query contains DELETE FROM users WHERE u.id = ?
//q.data contains  ['John Doe', '[email protected]', 1]

##Running Unit Tests

From inside the repository root, run npm install to install the node-tap dependency.

Run npm test to execute the complete test suite.

queryizejs's People

Contributors

twipped avatar greenkeeper[bot] avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.