overextended / oxmysql

MySQL resource for FXServer.
https://overextended.dev/oxmysql
GNU Lesser General Public License v3.0
316 stars 194 forks source link

Result type does not have length. #169

Closed tomasalves8 closed 1 year ago

tomasalves8 commented 1 year ago

Issue checklist

Describe the bug

When using typescript the editor shows that the Result type doesn't have length and can't by accessed by index. The code works fine, it's just a type error.

Screenshots If applicable, add screenshots to help explain your problem.

Code

    const result = await oxmysql.query('SELECT CONCAT(JSON_EXTRACT(charinfo, "$.firstname"), " ", JSON_EXTRACT(charinfo, "$.lastname")) AS name from players where id = ?', [charID]);
        if (result == null || result.length == 0) {
        return null;
    }else {
        let player = result[0];
        return player;
    }

Expected behavior Should not show any errors

Additional context

Server details

Database details

LukeWasTakenn commented 1 year ago

Use generics to type cast the result.