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


Golang db.UpdateByQField函數代碼示例

本文整理匯總了Golang中github.com/leanote/leanote/app/db.UpdateByQField函數的典型用法代碼示例。如果您正苦於以下問題:Golang UpdateByQField函數的具體用法?Golang UpdateByQField怎麽用?Golang UpdateByQField使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了UpdateByQField函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Api

// 升級為Api, beta.4
func (this *UpgradeService) Api(userId string) (ok bool, msg string) {
	if configService.GetGlobalStringConfig("UpgradeBetaToBeta4") != "" {
		return false, "Leanote have been upgraded"
	}

	// user
	db.UpdateByQField(db.Users, bson.M{}, "Usn", 200000)

	// notebook
	db.UpdateByQField(db.Notebooks, bson.M{}, "IsDeleted", false)
	this.setNotebookUsn()

	// note
	// 1-N
	db.UpdateByQField(db.Notes, bson.M{}, "IsDeleted", false)
	this.setNoteUsn()

	// tag
	// 1-N
	/// tag, 要重新插入, 將之前的Tag表遷移到NoteTag中
	this.moveTag()

	configService.UpdateGlobalStringConfig(userId, "UpgradeBetaToBeta4", "1")

	return true, ""
}
開發者ID:ClaudeXin,項目名稱:leanote,代碼行數:27,代碼來源:UpgradeService.go

示例2: ActiveTheme

// 使用主題
func (this *ThemeService) ActiveTheme(userId, themeId string) (ok bool) {
	if db.Has(db.Themes, bson.M{"_id": bson.ObjectIdHex(themeId), "UserId": bson.ObjectIdHex(userId)}) {
		// 之前的設為false
		db.UpdateByQField(db.Themes, bson.M{"UserId": bson.ObjectIdHex(userId), "IsActive": true}, "IsActive", false)
		// 現在的設為true
		db.UpdateByQField(db.Themes, bson.M{"_id": bson.ObjectIdHex(themeId)}, "IsActive", true)

		// UserBlog ThemeId
		db.UpdateByQField(db.UserBlogs, bson.M{"_id": bson.ObjectIdHex(userId)}, "ThemeId", bson.ObjectIdHex(themeId))
		return true
	}
	return false
}
開發者ID:ClaudeXin,項目名稱:leanote,代碼行數:14,代碼來源:ThemeService.go

示例3: ReCountNotebookNumberNotes

// 重新統計筆記本下的筆記數目
// noteSevice: AddNote, CopyNote, CopySharedNote, MoveNote
// trashService: DeleteNote (recove不用, 都統一在MoveNote裏了)
func (this *NotebookService) ReCountNotebookNumberNotes(notebookId string) bool {
	notebookIdO := bson.ObjectIdHex(notebookId)
	count := db.Count(db.Notes, bson.M{"NotebookId": notebookIdO, "IsTrash": false})
	Log(count)
	Log(notebookId)
	return db.UpdateByQField(db.Notebooks, bson.M{"_id": notebookIdO}, "NumberNotes", count)
}
開發者ID:sunyinhuiCoding,項目名稱:leanote,代碼行數:10,代碼來源:NotebookService.go

示例4: ResetPwd

// 管理員重置密碼
func (this *UserService) ResetPwd(adminUserId, userId, pwd string) (ok bool, msg string) {
	if configService.GetAdminUserId() != adminUserId {
		return
	}
	ok = db.UpdateByQField(db.Users, bson.M{"_id": bson.ObjectIdHex(userId)}, "Pwd", Md5(pwd))
	return
}
開發者ID:sunyinhuiCoding,項目名稱:leanote,代碼行數:8,代碼來源:UserService.go

示例5: UpdateShareNotebookPerm

func (this *ShareService) UpdateShareNotebookPerm(notebookId string, perm int, userId, toUserId string) bool {
	return db.UpdateByQField(db.ShareNotebooks,
		bson.M{"NotebookId": bson.ObjectIdHex(notebookId), "UserId": bson.ObjectIdHex(userId), "ToUserId": bson.ObjectIdHex(toUserId)},
		"Perm",
		perm,
	)
}
開發者ID:sunyinhuiCoding,項目名稱:leanote,代碼行數:7,代碼來源:ShareService.go

示例6: UpdatePwd

//----------------------
// 已經登錄了的用戶修改密碼
func (this *UserService) UpdatePwd(userId, oldPwd, pwd string) (bool, string) {
	userInfo := this.GetUserInfo(userId)
	if userInfo.Pwd != Md5(oldPwd) {
		return false, "舊密碼錯誤"
	}
	ok := db.UpdateByQField(db.Users, bson.M{"_id": bson.ObjectIdHex(userId)}, "Pwd", Md5(pwd))
	return ok, ""
}
開發者ID:hello-kukoo,項目名稱:leanote,代碼行數:10,代碼來源:UserService.go

示例7: PublicTheme

// 公開主題, 隻有管理員才有權限, 之前沒公開的變成公開
func (this *ThemeService) PublicTheme(userId, themeId string) (ok bool) {
	// 是否是管理員?
	userInfo := userService.GetUserInfo(userId)
	if userInfo.Username == configService.GetAdminUsername() {
		theme := this.GetThemeById(themeId)
		return db.UpdateByQField(db.Themes, bson.M{"UserId": bson.ObjectIdHex(userId), "_id": bson.ObjectIdHex(themeId)}, "IsDefault", !theme.IsDefault)
	}
	return false
}
開發者ID:ClaudeXin,項目名稱:leanote,代碼行數:10,代碼來源:ThemeService.go

示例8: setNoteUsn

func (this *UpgradeService) setNoteUsn() {
	usnI := 1
	notes := []info.Note{}
	db.ListByQWithFields(db.Notes, bson.M{}, []string{"UserId"}, &notes)

	for _, note := range notes {
		db.UpdateByQField(db.Notes, bson.M{"_id": note.NoteId}, "Usn", usnI)
		usnI++
	}
}
開發者ID:ClaudeXin,項目名稱:leanote,代碼行數:10,代碼來源:UpgradeService.go

示例9: IncrUsn

// 自增Usn
// 每次notebook,note添加, 修改, 刪除, 都要修改
func (this *UserService) IncrUsn(userId string) int {
	user := info.User{}
	query := bson.M{"_id": bson.ObjectIdHex(userId)}
	db.GetByQWithFields(db.Users, query, []string{"Usn"}, &user)
	usn := user.Usn
	usn += 1
	Log("inc Usn")
	db.UpdateByQField(db.Users, query, "Usn", usn)
	return usn
	//	return db.Update(db.Notes, bson.M{"_id": bson.ObjectIdHex(noteId)}, bson.M{"$inc": bson.M{"ReadNum": 1}})
}
開發者ID:rainkong,項目名稱:leanote,代碼行數:13,代碼來源:UserService.go

示例10: ResetPwd

// 管理員重置密碼
func (this *UserService) ResetPwd(adminUserId, userId, pwd string) (ok bool, msg string) {
	if configService.GetAdminUserId() != adminUserId {
		return
	}

	passwd := GenPwd(pwd)
	if passwd == "" {
		return false, "GenerateHash error"
	}
	ok = db.UpdateByQField(db.Users, bson.M{"_id": bson.ObjectIdHex(userId)}, "Pwd", passwd)
	return
}
開發者ID:rainkong,項目名稱:leanote,代碼行數:13,代碼來源:UserService.go

示例11: updateNoteAttachNum

// 更新筆記的附件個數
// addNum 1或-1
func (this *AttachService) updateNoteAttachNum(noteId bson.ObjectId, addNum int) bool {
	num := db.Count(db.Attachs, bson.M{"NoteId": noteId})
	/*
		note := info.Note{}
		note = noteService.GetNoteById(noteId.Hex())
		note.AttachNum += addNum
		if note.AttachNum < 0 {
			note.AttachNum = 0
		}
		Log(note.AttachNum)
	*/
	return db.UpdateByQField(db.Notes, bson.M{"_id": noteId}, "AttachNum", num)
}
開發者ID:sunyinhuiCoding,項目名稱:leanote,代碼行數:15,代碼來源:AttachService.go

示例12: UpdatePwd

//----------------------
// 已經登錄了的用戶修改密碼
func (this *UserService) UpdatePwd(userId, oldPwd, pwd string) (bool, string) {
	userInfo := this.GetUserInfo(userId)
	if !ComparePwd(oldPwd, userInfo.Pwd) {
		return false, "oldPasswordError"
	}

	passwd := GenPwd(pwd)
	if passwd == "" {
		return false, "GenerateHash error"
	}

	ok := db.UpdateByQField(db.Users, bson.M{"_id": bson.ObjectIdHex(userId)}, "Pwd", passwd)
	return ok, ""
}
開發者ID:rainkong,項目名稱:leanote,代碼行數:16,代碼來源:UserService.go

示例13: UpdatePwd

// 修改密碼
// 先驗證
func (this *PwdService) UpdatePwd(token, pwd string) (bool, string) {
	var tokenInfo info.Token
	var ok bool
	var msg string

	// 先驗證
	if ok, msg, tokenInfo = tokenService.VerifyToken(token, info.TokenPwd); !ok {
		return ok, msg
	}

	// 修改密碼之
	ok = db.UpdateByQField(db.Users, bson.M{"_id": tokenInfo.UserId}, "Pwd", Md5(pwd))

	// 刪除token
	tokenService.DeleteToken(tokenInfo.UserId.Hex(), info.TokenPwd)

	return ok, ""
}
開發者ID:hello-kukoo,項目名稱:leanote,代碼行數:20,代碼來源:PwdService.go

示例14: SortSingles

// 重新排序
func (this *BlogService) SortSingles(userId string, singleIds []string) (ok bool) {
	if singleIds == nil || len(singleIds) == 0 {
		return
	}
	userBlog := this.GetUserBlog(userId)
	singles := userBlog.Singles
	if singles == nil || len(singles) == 0 {
		return
	}

	singlesMap := map[string]map[string]string{}
	for _, page := range singles {
		singlesMap[page["SingleId"]] = page
	}

	singles2 := make([]map[string]string, len(singles))
	for i, singleId := range singleIds {
		singles2[i] = singlesMap[singleId]
	}

	return db.UpdateByQField(db.UserBlogs, bson.M{"_id": bson.ObjectIdHex(userId)}, "Singles", singles2)
}
開發者ID:ZypcGroup,項目名稱:leanote,代碼行數:23,代碼來源:BlogService.go

示例15: UpdatePwd

// 修改密碼
// 先驗證
func (this *PwdService) UpdatePwd(token, pwd string) (bool, string) {
	var tokenInfo info.Token
	var ok bool
	var msg string

	// 先驗證
	if ok, msg, tokenInfo = tokenService.VerifyToken(token, info.TokenPwd); !ok {
		return ok, msg
	}
	digest, err := GenerateHash(pwd)
	if err != nil {
		return false, "GenerateHash error"
	}
	passwd := string(digest)
	// 修改密碼之
	ok = db.UpdateByQField(db.Users, bson.M{"_id": tokenInfo.UserId}, "Pwd", passwd)

	// 刪除token
	tokenService.DeleteToken(tokenInfo.UserId.Hex(), info.TokenPwd)

	return ok, ""
}
開發者ID:howardroark2018,項目名稱:leanote-all,代碼行數:24,代碼來源:PwdService.go


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