1.0.5 • Published 4 years ago

wind-sql v1.0.5

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

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
1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago