0.1.8 • Published 9 years ago
mysql-types v0.1.8
Usage
var mysqlType = require('mysql-types');
Conversions
JS Type | MySQL Type |
---|---|
string | VARCHAR (automatically converted to TEXT when adding more characters) |
number | SMALLINT |
boolean | TINYINT(1) |
date | DATETIME |
function | tries if function is constructor and uses type of instance else Error |
object | Error |
array | Error |
Examples
let string = mysqlType('string') // VARCHAR
let string = mysqlType(String) // VARCHAR
let number = mysqlType(123) // SMALLINT
let number = mysqlType(Number) // SMALLINT
let date = mysqlType(new Date()) // DATETIME
let date = mysqlType(Date) // DATETIME
let bool = mysqlType(true) // TINYINT(1)
let bool = mysqlType(Boolean) // TINYINT(1)