Instance insertion fails

#1

A Country hasMany() Town

I can add countries in CountryController.store() with the same code as below, but in TownController.store() I am having an issue:

class TownController {                                                                                                                           
  async store({ request, response }) {                                                                                                           
    const info = request.post()                                                                                                                  
    console.log(info)     // OK                                                                                                                       
    const town = new Town()                                                                                                                      
    town.name = info.name                                                                                                                        
    town.country_name = info.country_name                                                                                                        
    console.log(town)       // OK                                                                                                                     
    await town.save()       //  Error 500                                                                                                                                                                                                                                    
  }                                                                                                                                              
}

What am I missing?

0 Likes

#2

Sorry, I had a typo in the town’s column name.

0 Likes