Created
July 15, 2024 22:31
-
-
Save BK1031/8ebe998f1c7b5001e8d38b9d0230af2b to your computer and use it in GitHub Desktop.
singlestore-go-bookstore updated CreateBook function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package service | |
import ( | |
"bookstore/database" | |
"bookstore/model" | |
) | |
func CreateBook(book model.Book) (model.Book, error) { | |
result := database.DB.Create(&book) | |
if result.Error != nil { | |
return model.Book{}, result.Error | |
} | |
return book, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment