1.0.5 • Published 4 years ago
wind-sql v1.0.5
wind-sql
Table of Contents
- Install
- Introduction
- QUERY
- INSERT
- UPDATE_BY_ID
- UPDATE_BY_COLUMN
- DELETE_BY_ID
- SELECT_BY_ID
- SELECT_ALL
- SELECT_BY_COLUMN
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