Getting the number of rows created

Report a typo

Suppose you are working with the music database, and you have just created and inserted the following records of songs into the songs table:

func main() {
    ... // Connect to the `music` database using gorm.Open()

    songs := []Song{
        {Title: "Here Comes The Sun", Duration: 3*time.Minute + 05*time.Second},
        {Title: "Let It Be", Duration: 5*time.Minute + 31*time.Second},
        {Title: "Come Together", Duration: 4*time.Minute + 19*time.Second},
        {Title: "Yesterday", Duration: 2*time.Minute + 05*time.Second},
        {Title: "Twist And Shout", Duration: 2*time.Minute + 35*time.Second},
    }
    result := db.Create(&songs)
    fmt.Println(result.?) // What field indicates the number of created rows?
}

What field from the result struct indicates the number of created rows?

Enter a short text
___

Create a free account to access the full topic