master
yutent 2024-07-23 18:54:00 +08:00
parent f0366b9d2d
commit 4d79480e72
4 changed files with 19 additions and 13 deletions

View File

@ -29,7 +29,7 @@ class Mysqli {
host, host,
port, port,
user, user,
charset, charset = 'utf8mb4',
passwd: password, passwd: password,
db: database, db: database,
timezone, timezone,
@ -39,7 +39,6 @@ class Mysqli {
let name = i < 1 ? 'MASTER' : 'SLAVE' + i let name = i < 1 ? 'MASTER' : 'SLAVE' + i
let collate let collate
charset = charset || 'utf8mb4'
collate = collate =
charset + (charset === 'utf8mb4' ? '_0900_ai_ci' : '_general_ci') charset + (charset === 'utf8mb4' ? '_0900_ai_ci' : '_general_ci')

View File

@ -79,7 +79,6 @@ class Api {
if (!this.db && db) { if (!this.db && db) {
return Promise.reject('No database selected.') return Promise.reject('No database selected.')
} }
let defer = Promise.defer()
return this.query(`DROP DATABASE IF EXISTS ${db || this.db}`) return this.query(`DROP DATABASE IF EXISTS ${db || this.db}`)
} }

View File

@ -128,7 +128,18 @@ class Method {
} }
} }
let { table, leftJoin, rightJoin, join, filter, fields, sort, skip, size, limit } = this.cache let {
table,
leftJoin,
rightJoin,
join,
filter,
fields,
sort,
skip,
size,
limit
} = this.cache
// 没有使用 slice方法的前提下, 通过skip/limit补全 // 没有使用 slice方法的前提下, 通过skip/limit补全
if (!limit) { if (!limit) {

View File

@ -8,10 +8,7 @@ const { escape } = require('mysql')
function hideProperty(host, name, value) { function hideProperty(host, name, value) {
Object.defineProperty(host, name, { Object.defineProperty(host, name, {
value: value, value: value
writable: true,
enumerable: false,
configurable: true
}) })
} }
@ -19,11 +16,9 @@ function getType(val) {
if (val === null) { if (val === null) {
return String(val) return String(val)
} }
return Object.prototype.toString return Object.prototype.toString.call(val).slice(8, -1).toLowerCase()
.call(val)
.slice(8, -1)
.toLowerCase()
} }
function parse$or(arr) { function parse$or(arr) {
let sql = '' let sql = ''
for (let it of arr) { for (let it of arr) {
@ -299,7 +294,9 @@ class SqlErr {
hideProperty(this, 'stack', msg) hideProperty(this, 'stack', msg)
console.error( console.error(
line + line +
`\n[${new Date().format('Y/m/d_H:i:s')}][Last Query SQL]: ${sql}\nQuery ${msg}\n` + `\n[${new Date().format(
'Y/m/d_H:i:s'
)}][Last Query SQL]: ${sql}\nQuery ${msg}\n` +
line line
) )
} }