Skipping retrieved books

Report a typo

Erick has just started working with an in-memory version of the library.db SQLite database; below, you can see the database diagram:

library database

Erick has created a Go program that retrieves and scans the values of the Publisher named "Bloomsbury" into the publisher struct.

Now he wants to retrieve all Book records NOT (!=) published by "Bloomsbury", skip the 25 initial records and then print them. Your task is to help Erick write the additional required code to achieve this.

Write a program in Go
package main

import (
"fmt"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"log"
"time"
)

// DO NOT modify the model declarations below!
type Author struct { // Model for the `authors` table
gorm.Model
Name string
Books []Book `gorm:"many2many:author_books"`
}

type Book struct { // Model for the `books` table
gorm.Model
Title string
DatePublished time.Time
PublisherID uint
Authors []Author `gorm:"many2many:author_books"`
}

type Publisher struct { // Model for the `publishers` table
gorm.Model
Name string
Books []Book
}

// nolint:gomnd // DO NOT delete this comment!
func main() {
db := createDB() // DO NOT delete this line! it creates the in-memory `library` database

var publisher Publisher
___

Create a free account to access the full topic