Skip to content

Commit

Permalink
reafactor: add error
Browse files Browse the repository at this point in the history
  • Loading branch information
Caixetadev committed Jan 31, 2024
1 parent 6a13a41 commit af22ce9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/database/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ func GetDocByCheckSum(checksum []byte) models.Doc {
return entries
}

func AddDoc(doc models.Doc) string {
DB.Create(&doc)
func AddDoc(doc models.Doc) (string, error) {
result := DB.Create(&doc)
if result.Error != nil {
return "", result.Error
}

return doc.FileName
return doc.FileName, result.Error
}

func DeleteDoc(fileName string) (string, bool) {
Expand Down

0 comments on commit af22ce9

Please sign in to comment.