MCPcopy Index your code
hub / github.com/dnote/dnote / DeleteNote

Method DeleteNote

pkg/server/app/notes.go:129–145  ·  view source on GitHub ↗

DeleteNote marks a note deleted with the next usn and updates the user's max_usn

(tx *gorm.DB, user database.User, note database.Note)

Source from the content-addressed store, hash-verified

127
128// DeleteNote marks a note deleted with the next usn and updates the user's max_usn
129func (a *App) DeleteNote(tx *gorm.DB, user database.User, note database.Note) (database.Note, error) {
130 nextUSN, err := incrementUserUSN(tx, user.ID)
131 if err != nil {
132 return note, pkgErrors.Wrap(err, "incrementing user max_usn")
133 }
134
135 if err := tx.Model(&note).
136 Updates(map[string]interface{}{
137 "usn": nextUSN,
138 "deleted": true,
139 "body": "",
140 }).Error; err != nil {
141 return note, pkgErrors.Wrap(err, "deleting note")
142 }
143
144 return note, nil
145}
146
147// GetUserNoteByUUID retrives a digest by the uuid for the given user
148func (a *App) GetUserNoteByUUID(userID int, uuid string) (*database.Note, error) {

Callers 3

delMethod · 0.80
delMethod · 0.80
TestDeleteNoteFunction · 0.80

Calls 1

incrementUserUSNFunction · 0.85

Tested by 1

TestDeleteNoteFunction · 0.64