GetNoteInfo returns a NoteInfo for the note with the given noteRowID
(db *DB, noteRowID int)
| 90 | |
| 91 | // GetNoteInfo returns a NoteInfo for the note with the given noteRowID |
| 92 | func GetNoteInfo(db *DB, noteRowID int) (NoteInfo, error) { |
| 93 | var ret NoteInfo |
| 94 | |
| 95 | err := db.QueryRow(`SELECT books.label, notes.uuid, notes.body, notes.added_on, notes.edited_on, notes.rowid |
| 96 | FROM notes |
| 97 | INNER JOIN books ON books.uuid = notes.book_uuid |
| 98 | WHERE notes.rowid = ? AND notes.deleted = false`, noteRowID). |
| 99 | Scan(&ret.BookLabel, &ret.UUID, &ret.Content, &ret.AddedOn, &ret.EditedOn, &ret.RowID) |
| 100 | if err == sql.ErrNoRows { |
| 101 | return ret, errors.Errorf("note %d not found", noteRowID) |
| 102 | } else if err != nil { |
| 103 | return ret, errors.Wrap(err, "querying the note") |
| 104 | } |
| 105 | |
| 106 | return ret, nil |
| 107 | } |
| 108 | |
| 109 | // BookInfo is a basic information about a book |
| 110 | type BookInfo struct { |