Luccas
Luccas
Explore posts from servers
KKysely
Created by Luccas on 10/1/2023 in #help
jsonb_build_object and raw sql possibilities
too elegant, tks
5 replies
KKysely
Created by Luccas on 3/23/2023 in #help
mysql InsertResult always empty
i exaggerated a bit when I said that my app was transaction heavy user haha
17 replies
KKysely
Created by Luccas on 3/23/2023 in #help
mysql InsertResult always empty
I agree with you
17 replies
KKysely
Created by Luccas on 3/23/2023 in #help
mysql InsertResult always empty
Does this not cause performance issues?
17 replies
KKysely
Created by Luccas on 3/23/2023 in #help
mysql InsertResult always empty
worked, thanks
17 replies
KKysely
Created by Luccas on 3/23/2023 in #help
mysql InsertResult always empty
* Kysely version - "kysely": "^0.23.5" * Which dialect are you using - i tried PlanetScaleDialect and MysqlDialect, same result in both * The exact code you're trying to run
return db.transaction().execute(async (trx) => {
await trx
.insertInto('user')
.values({
first_name: firstName,
last_name: lastName,
public_id: userPublicId,
password: hashPass,
email: email,
})
.executeTakeFirst()
.then(console.log);

const userId = (await sql<{ id: number }>`SELECT LAST_INSERT_ID() AS id`.execute(trx)).rows[0].id;

return trx
.insertInto('user_providers')
.values({
provider,
user_id: userId,
provider_id: userId.toString(),
})
.execute();
});
return db.transaction().execute(async (trx) => {
await trx
.insertInto('user')
.values({
first_name: firstName,
last_name: lastName,
public_id: userPublicId,
password: hashPass,
email: email,
})
.executeTakeFirst()
.then(console.log);

const userId = (await sql<{ id: number }>`SELECT LAST_INSERT_ID() AS id`.execute(trx)).rows[0].id;

return trx
.insertInto('user_providers')
.values({
provider,
user_id: userId,
provider_id: userId.toString(),
})
.execute();
});
* How it fails - the received return from console.log is [ InsertResult {} ] * What are you expecting to happen - return id of insert * Any errors you see - no errors
17 replies
KKysely
Created by Luccas on 3/23/2023 in #help
mysql InsertResult always empty
now i doing an workaround like this
.values({
provider,
user_id: sql<number>`LAST_INSERT_ID()`,
provider_id: sql<string>`LAST_INSERT_ID()`,
})
.values({
provider,
user_id: sql<number>`LAST_INSERT_ID()`,
provider_id: sql<string>`LAST_INSERT_ID()`,
})
17 replies