No id returned (mysql2)

async function create(data: NewBusiness) {
return client.insert(business).values(data)
}
async function create(data: NewBusiness) {
return client.insert(business).values(data)
}
returns
headers: [],
types: {},
fields: [],
rows: [],
rowsAffected: 1,
insertId: '0',
size: 0,
statement: ...
headers: [],
types: {},
fields: [],
rows: [],
rowsAffected: 1,
insertId: '0',
size: 0,
statement: ...
I need Id. Tried to add .execute() a the end but same thing.
2 Replies
MAST
MAST14mo ago
Did you try .returning() after the insert? But that depends on the db you are using.
Angelelz
Angelelz14mo ago
MySql doesn't have the returning method. But if you are using the .$default() method, MySql will not return back the id because technically you provided it to the DB via your custom default
Want results from more Discord servers?
Add your server