wind-sql

1.0.5 • Public • Published

wind-sql

NPM Version NPM Downloads Node.js Version

Table of Contents

Install

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 0.6 or higher is required.

Installation is done using the npm install command:

$ npm install wind-sql

Introduction

This is a node.js framework for mysql. It is written in JavaScript, does not require compiling, and is 100% MIT licensed.

Here is an example on how to use it:

var windSQL    = require('wind-sql');
var mysql      = require('mysql');
var pool = mysql.createPool({
  host     : 'localhost',
  user     : 'me',
  password : 'secret',
  database : 'my_db'
});
 
windSQL.initSSQL({
    mysql: pool,
    resultUseCamelCase: true,
});
 

QUERY

var windSQL = require('wind-sql');
windSQL.initSSQL({
    mysql: pool,
    resultUseCamelCase: true,
});
 
await windSQL.query('select * from user whre id = ?', [21]);
 
  • windSQL.query(sql, args);
  • require sql type is String
  • require args type is Array

INSERT

var windSQL = require('wind-sql');
windSQL.initSSQL({
    mysql: pool,
    resultUseCamelCase: true,
});
 
let cat = {
    name: 'Tom',
    age: 12,
};
await windSQL.insert(cat, 'cat');
 
  • windSQL.insert(model, table);id cannot appear in attribute.
  • require model
  • require table

UPDATE_BY_ID

var windSQL = require('wind-sql');
windSQL.initSSQL({
    mysql: pool,
    resultUseCamelCase: true,
});
 
let cat = {
    id: 1,
    name: 'Tom',
    age: 12,
};
await windSQL.updateById(cat, 'cat');
 
  • windSQL.updateById(model, table);
  • require model
  • require table

UPDATE_BY_COLUMN

  • developing

DELETE_BY_ID

var windSQL = require('wind-sql');
windSQL.initSSQL({
    mysql: pool,
    resultUseCamelCase: true,
});
 
await windSQL.deleteById(1, 'cat');
 
  • windSQL.deleteById(id, table);
  • require id
  • require table

SELECT_BY_ID

var windSQL = require('wind-sql');
windSQL.initSSQL({
    mysql: pool,
    resultUseCamelCase: true,
});
 
await windSQL.selectById(1, 'cat');
 
  • windSQL.selectById(id, table);
  • require id
  • require table

SELECT_ALL

var windSQL = require('wind-sql');
windSQL.initSSQL({
    mysql: pool,
    resultUseCamelCase: true,
});
 
await windSQL.selectAll('cat');
 
  • windSQL.selectAll(table);
  • require table.

SELECT_BY_COLUMN

  • developing

Readme

Keywords

Package Sidebar

Install

npm i wind-sql

Weekly Downloads

2

Version

1.0.5

License

MIT

Unpacked Size

65.3 kB

Total Files

12

Last publish

Collaborators

  • hvaexlove