當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Notebook.DeleteAll方法代碼示例

本文整理匯總了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)
}
開發者ID:oschmid,項目名稱:tessernote,代碼行數:17,代碼來源:data.go

示例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)
}
開發者ID:oschmid,項目名稱:tessernote,代碼行數:26,代碼來源:data.go


注:本文中的github.com/oschmid/tessernote.Notebook.DeleteAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。