Я использую Adonis JS и MS SQL. У меня есть несколько баз данных на одном сервере: https://i.imgur.com/d4Eqfpt.png
В моем .env у меня есть эта конфигурация:
DB_CONNECTION=mssql
DB_HOST=127.0.0.1
DB_PORT=1433
DB_USER=sa
DB_PASSWORD=123456
DB_DATABASE=WEB_PANEL
Проблема в том, что у меня есть свой API для выполнения таких запросов:
connectToDatabase('mssql://id:pw@localhost').then(async () => {
let onlinePlayers = await User.getOnlinePlayers()
let numberOfStaff = staff.length
let numberOfOnlinePlayers = onlinePlayers.recordset.length
return view.render('system.index', { totalPlayers: numberOfOnlinePlayers, numberOfStaff: numberOfStaff })
})
}
И у меня есть эта ошибка:
warning:
warning:
WARNING: Adonis has detected an unhandled promise rejection, which may
cause undesired behavior in production.
To stop this warning, use catch() on promises or wrap await
calls inside try/catch.
TypeError: Cannot read property 'substr' of null
at parseConnectionURI (C:\Users\didi\Desktop\drpanel\panel\node_modules\mssql\lib\connectionstring.js:21:32)
at Object.resolveConnectionString [as resolve] (C:\Users\didi\Desktop\drpanel\panel\node_modules\mssql\lib\connectionstring.js:205:72)
at new ConnectionPool (C:\Users\didi\Desktop\drpanel\panel\node_modules\mssql\lib\base.js:127:40)
at new ConnectionPool (C:\Users\didi\Desktop\drpanel\panel\node_modules\mssql\lib\tedious.js:175:1)
at Object.connect (C:\Users\didi\Desktop\drpanel\panel\node_modules\mssql\lib\base.js:1592:22)
at connectToDatabase (C:\Users\didi\Desktop\drpanel\panel\drapi\src\core\connection.handler.js:4:15)
at SystemController.showSystemPage (C:\Users\didi\Desktop\drpanel\panel\app\Controllers\Http\Panel\SystemController.js:8:9)
at Server._routeHandler (C:\Users\didi\Desktop\drpanel\panel\node_modules\@adonisjs\framework\src\Server\index.js:121:31)
at MiddlewareBase._resolveMiddleware (C:\Users\didi\Desktop\drpanel\panel\node_modules\@adonisjs\middleware-base\index.js:195:28)
at Runnable._invoke (C:\Users\didi\Desktop\drpanel\panel\node_modules\co-compose\src\Runnable.js:76:42)
at C:\Users\didi\Desktop\drpanel\panel\node_modules\co-compose\src\Runnable.js:73:34
at f (C:\Users\didi\Desktop\drpanel\panel\node_modules\once\once.js:25:25)
at Authenticated.handle (C:\Users\didi\Desktop\drpanel\panel\app\Middleware\Authenticated.js:16:19)
at async ConvertEmptyStringsToNull.handle (C:\Users\didi\Desktop\drpanel\panel\app\Middleware\ConvertEmptyStringsToNull.js:13:5)
at async AuthInit.handle (C:\Users\didi\Desktop\drpanel\panel\node_modules\@adonisjs\auth\src\Middleware\AuthInit.js:60:5)
at async Shield.handle (C:\Users\didi\Desktop\drpanel\panel\node_modules\@adonisjs\shield\src\Shield\index.js:417:5)
И, например, getOnlinePlayers ():
static async getOnlinePlayers() {
let onlinePlayers = await sql.query`
USE DR2_USER
SELECT TOP 10 * FROM TB_CharacterSub
WHERE f_ConnectionChannel != 0`
return onlinePlayers
}
Например Я хочу использовать базу данных DR2_USER, но не могу: /
Пожалуйста, у кого-нибудь есть решение?
Спасибо!