0.1.1 • Published 1 year ago
@blued-core-oversea/mysql-client v0.1.1
基于 sequelize 的一层封装。
npm i @blued-core-oversea/mysql-client
import BattleRecord from './models/battle-record'
export const mysql = {
liveArchive: {
qconf: '/blued/backend/udb/live_archive',
database: 'record_oversea',
modelPath: path.resolve(__dirname, './models'),
},
}
// 线上logging 参数建议设置为false
const client = new MysqlClient(mysql, {
logging: true,
})
export const misOverseaMysqlClient = () => client.getClient('liveArchive')
const main = async () => {
for (let i = 0; i <= 10; i++) {
const pk = await BattleRecord.findOne({
where: {
pkId: '23423434342342342424',
},
raw: true,
})
console.log(pk)
const result = await misOverseaMysqlClient().query(`SELECT pk_id AS pkId FROM battle_record WHERE pk_id = '23423434342342342424'`, {
raw: true,
})
console.log((result))
}
}
main().then(() => {
console.log('success')
}).catch(error => {
console.log(error)
})