package comments import ( "time" "git.aiterp.net/rpdata/api/models" ) // Add adds a comment. func Add(chapter models.Chapter, subject, author, source, characterName string, character *models.Character, createdDate time.Time, fictionalDate time.Time) (models.Comment, error) { characterID := "" if character != nil { characterID = character.ID } comment := models.Comment{ ID: makeCommentID(), ChapterID: chapter.ID, Subject: subject, Author: author, CharacterName: characterName, CharacterID: characterID, FictionalDate: fictionalDate, CreatedDate: createdDate, EditedDate: createdDate, Source: source, } err := collection.Insert(comment) if err != nil { return models.Comment{}, err } return comment, nil }