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

Method UpdateNote

pkg/server/app/notes.go:104–126  ·  view source on GitHub ↗

UpdateNote creates a note with the next usn and updates the user's max_usn

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

Source from the content-addressed store, hash-verified

102
103// UpdateNote creates a note with the next usn and updates the user's max_usn
104func (a *App) UpdateNote(tx *gorm.DB, user database.User, note database.Note, p *UpdateNoteParams) (database.Note, error) {
105 nextUSN, err := incrementUserUSN(tx, user.ID)
106 if err != nil {
107 return note, pkgErrors.Wrap(err, "incrementing user max_usn")
108 }
109
110 if p.BookUUID != nil {
111 note.BookUUID = p.GetBookUUID()
112 }
113 if p.Content != nil {
114 note.Body = p.GetContent()
115 }
116
117 note.USN = nextUSN
118 note.EditedOn = a.Clock.Now().UnixNano()
119 note.Deleted = false
120
121 if err := tx.Save(&note).Error; err != nil {
122 return note, pkgErrors.Wrap(err, "editing note")
123 }
124
125 return note, nil
126}
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) {

Callers 3

updateMethod · 0.80
TestUpdateNoteFunction · 0.80

Calls 4

incrementUserUSNFunction · 0.85
GetBookUUIDMethod · 0.80
GetContentMethod · 0.80
NowMethod · 0.65

Tested by 2

TestUpdateNoteFunction · 0.64