How update row in database


How its possible to update the row when it already exists in the table please ?

Here is my code :
The problem is if the row already exists, i have this error :

Thanks :slightly_smiling_face:


use await when call save() -> await

To modify the record:

const summoner= await SummonerData.find(<id>)
// Modify the different fields

Lucid documentation - find()

Is the problem solved?
Have a good day

Doesn’t work but I found the solution :slight_smile:

   try {
    const summoner = await SummonerData.create({
      name: name
    console.log('Summoner created !')
  } catch (error) {
    const summonerAlreadyRegistered = await SummonerData.findBy('name', name) =
    console.log('Summoner saved !')

I just removed rows in the db but the principe is the same:)

Thanks !


I am really looking forward to this product finished. Fellow summoner here :slight_smile:

Also another suggestion is to put your validation in it’s own file, and make API url dynamic (you don’t want EUW only, right?)

Instead of firing a query to search for a summoner to check if it exists or not, you can use findorcreate


try {
    const summoner = await SummoerData.findOrCreate({ name: name });
    console.log('Summoner Created')
} catch (e) {
1 Like