More stuff

This commit is contained in:
Melody Becker 2024-09-15 15:18:05 +02:00
parent 71beed7eb3
commit 9a7e420c83
7 changed files with 63 additions and 33 deletions

View file

@ -107,7 +107,9 @@ func (s *Storage) UpdateNote(note *Note) error {
}
err = s.cache.Set(cacheNoteIdToNotePrefix+note.ID, note)
if err != nil {
log.Warn().Err(err).Msg("Failed to update note into cache. Cache and db might be out of sync, a force sync is recommended")
log.Warn().
Err(err).
Msg("Failed to update note into cache. Cache and db might be out of sync, a force sync is recommended")
}
return nil
}
@ -121,13 +123,3 @@ func (s *Storage) DeleteNote(id string) {
s.cache.Delete(cacheNoteIdToNotePrefix + id)
s.db.Delete(Note{ID: id})
}
// Try and find a note with a given ID
func (store *Storage) FindNoteById(id string) (*Note, error) {
note := Note{}
res := store.db.First(&note, id)
if res.Error != nil {
return nil, res.Error
}
return &note, nil
}