本文整理匯總了Golang中github.com/oschmid/tessernote.Notebook.DeleteAll方法的典型用法代碼示例。如果您正苦於以下問題:Golang Notebook.DeleteAll方法的具體用法?Golang Notebook.DeleteAll怎麽用?Golang Notebook.DeleteAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/oschmid/tessernote.Notebook
的用法示例。
在下文中一共展示了Notebook.DeleteAll方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: DeleteAllNotes
// DeleteAllNotes deletes all Notes from the authorized User's Notebook. It writes true if Notes were deleted,
// and false if the Notebook was empty to w.
func DeleteAllNotes(w http.ResponseWriter, c appengine.Context, notebook *tessernote.Notebook) {
empty := len(notebook.NoteKeys) == 0
err := notebook.DeleteAll(c)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
reply, err := json.Marshal(!empty)
if err != nil {
c.Errorf("marshaling delete all response: %s", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Write(reply)
}
示例2: ReplaceAllNotes
// ReplaceAllNotes replaces the Notes of the authorized User's Notebook with a new set of Notes. It takes as
// input a JSON formatted list of Notes and writes the added notes if succeeded or an error message otherwise to w.
// Notes may be written back with different IDs than those submitted, see ReplaceNote().
func ReplaceAllNotes(w http.ResponseWriter, r *http.Request, c appengine.Context, notebook *tessernote.Notebook) {
notes, err := readNotes(w, r)
if err != nil {
return
}
err = notebook.DeleteAll(c)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
notes, err = notebook.PutAll(notes, c)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
reply, err := json.Marshal(notes)
if err != nil {
c.Errorf("marshaling notes (%d): %s", len(notes), err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Write(reply)
}