GetActiveNote gets the note which has the given rowid and is not deleted
(db *DB, rowid int)
| 157 | |
| 158 | // GetActiveNote gets the note which has the given rowid and is not deleted |
| 159 | func GetActiveNote(db *DB, rowid int) (Note, error) { |
| 160 | var ret Note |
| 161 | |
| 162 | err := db.QueryRow(`SELECT |
| 163 | rowid, |
| 164 | uuid, |
| 165 | book_uuid, |
| 166 | body, |
| 167 | added_on, |
| 168 | edited_on, |
| 169 | usn, |
| 170 | deleted, |
| 171 | dirty |
| 172 | FROM notes WHERE rowid = ? AND deleted = false;`, rowid).Scan( |
| 173 | &ret.RowID, |
| 174 | &ret.UUID, |
| 175 | &ret.BookUUID, |
| 176 | &ret.Body, |
| 177 | &ret.AddedOn, |
| 178 | &ret.EditedOn, |
| 179 | &ret.USN, |
| 180 | &ret.Deleted, |
| 181 | &ret.Dirty, |
| 182 | ) |
| 183 | |
| 184 | if err == sql.ErrNoRows { |
| 185 | return ret, err |
| 186 | } else if err != nil { |
| 187 | return ret, errors.Wrap(err, "finding the note") |
| 188 | } |
| 189 | |
| 190 | return ret, nil |
| 191 | } |
| 192 | |
| 193 | // UpdateNoteContent updates the note content and marks the note as dirty |
| 194 | func UpdateNoteContent(db *DB, c clock.Clock, rowID int, content string) error { |