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


Golang qbs.Qbs類代碼示例

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


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

示例1: HandlePanic

//HandlePanic rolls back the transiction provided and then panics again.
func (self *QbsDefaultOrmTransactionPolicy) HandlePanic(tx *qbs.Qbs, err interface{}) (interface{}, error) {
	log.Printf("got panic, rolling back and returning 500 to client (%v)\n", err)
	if rerr := tx.Rollback(); rerr != nil {
		panic(rerr)
	}
	return nil, HTTPError(http.StatusInternalServerError, fmt.Sprintf("panic: %v", err))
}
開發者ID:seven5,項目名稱:seven5,代碼行數:8,代碼來源:qbs_store.go

示例2: updateImportInfo

func updateImportInfo(q *qbs.Qbs, path string, pid int, add bool) {
	// Save package information.
	info := new(PkgInfo)
	err := q.WhereEqual("path", path).Find(info)
	if err == nil {
		// Check if pid exists in this project.
		i := strings.Index(info.ImportPid, "$"+strconv.Itoa(pid)+"|")
		switch {
		case i == -1 && add: // Add operation and does not contain.
			info.ImportPid += "$" + strconv.Itoa(pid) + "|"
			info.ImportedNum++
			_, err = q.Save(info)
			if err != nil {
				beego.Error("models.updateImportInfo(): add:", path, err)
			}
		case i > -1 && !add: // Delete operation and contains.
			info.ImportPid = strings.Replace(info.ImportPid, "$"+strconv.Itoa(pid)+"|", "", 1)
			info.ImportedNum--
			if err != nil {
				beego.Error("models.updateImportInfo(): delete:", path, err)
			}
		}
	}

	// Error means this project does not exist, simply skip.
}
開發者ID:sywxf,項目名稱:gowalker,代碼行數:26,代碼來源:models.go

示例3: UpdateMultipleUsers

func UpdateMultipleUsers(q *qbs.Qbs) (affected int64, err error) {
	type User struct {
		Name string
	}
	user := new(User)
	user.Name = "Blue"
	return q.WhereEqual("name", "Green").Update(user)
}
開發者ID:nonempty,項目名稱:qbs,代碼行數:8,代碼來源:example.go

示例4: Save

//保存
func (this *Episode) Save(q *qbs.Qbs) bool {
	_, err := q.Save(this)
	if err != nil {
		fmt.Println(err)
		return false
	}
	return true
}
開發者ID:river-lee,項目名稱:qishare,代碼行數:9,代碼來源:episode.go

示例5: FindUserByCondition

func FindUserByCondition(q *qbs.Qbs) (*User, error) {
	user := new(User)
	condition1 := qbs.NewCondition("id > ?", 100).Or("id < ?", 50).OrEqual("id", 75)
	condition2 := qbs.NewCondition("name != ?", "Red").And("name != ?", "Black")
	condition1.AndCondition(condition2)
	err := q.Condition(condition1).Find(user)
	return user, err
}
開發者ID:nonempty,項目名稱:qbs,代碼行數:8,代碼來源:example.go

示例6: UpdateOneUser

func UpdateOneUser(q *qbs.Qbs, id int64, name string) (affected int64, err error) {
	user, err := FindUserById(q, id)
	if err != nil {
		return 0, err
	}
	user.Name = name
	return q.Save(user)
}
開發者ID:nonempty,項目名稱:qbs,代碼行數:8,代碼來源:example.go

示例7: Save

//保存
func (p *Person) Save(q *qbs.Qbs) bool {
	_, err := q.Save(p)
	if err != nil {
		fmt.Println(err)
		return false
	}
	return true
}
開發者ID:river-lee,項目名稱:qishare,代碼行數:9,代碼來源:person.go

示例8: StartTransaction

//StartTransaction returns a new qbs object after creating the transaction.
func (self *QbsDefaultOrmTransactionPolicy) StartTransaction(q *qbs.Qbs) *qbs.Qbs {
	if err := q.Begin(); err != nil {
		if err.Error() == "EOF" {
			log.Printf("It's likely there is something listening on your server port that isn't the database you expected.")
		}
		panic(err)
	}
	return q
}
開發者ID:seven5,項目名稱:seven5,代碼行數:10,代碼來源:qbs_store.go

示例9: update

//更新
func (p *Person) update(person Person, q *qbs.Qbs) bool {

	_, err := q.Update(person)
	if err != nil {
		fmt.Println(err)
		return false
	}
	return true
}
開發者ID:river-lee,項目名稱:qishare,代碼行數:10,代碼來源:person.go

示例10: PrintTable

func PrintTable(q *qbs.Qbs) {
	var users []*User

	q.FindAll(&users)

	for _, user := range users {
		fmt.Printf("%+v,", user)
	}
	fmt.Println()
}
開發者ID:GoSteelProgrammers,項目名稱:talk-review-orms,代碼行數:10,代碼來源:relationship.go

示例11: Save

//保存
func (u *User) Save(q *qbs.Qbs) bool {
	if u.Password != "" {
		//u.HashedPassword = EncryptPassword(u.Password)
	}

	_, err := q.Save(u)
	if err != nil {
		fmt.Println(err)
		return false
	}
	return true
}
開發者ID:river-lee,項目名稱:qishare,代碼行數:13,代碼來源:user.go

示例12: PostQbs

func (self *testObjUdid) PostQbs(value interface{}, pb PBundle, q *qbs.Qbs) (interface{}, error) {
	self.testCallCount++
	in := value.(*HouseWireUdid)
	house := &HouseUdid{Id: in.Id, Address: in.Addr, Zip: in.ZipCode}
	if house.Id == "" {
		house.Id = UDID()
	}
	if _, err := q.Save(house); err != nil {
		return nil, err
	}

	return &HouseWireUdid{Id: house.Id, Addr: house.Address, ZipCode: house.Zip}, nil
}
開發者ID:seven5,項目名稱:seven5,代碼行數:13,代碼來源:qbs_rest_test.go

示例13: getGroupPkgInfoWithQ

func getGroupPkgInfoWithQ(q *qbs.Qbs, paths []string) []*hv.PkgInfo {
	pinfos := make([]*hv.PkgInfo, 0, len(paths))
	for _, v := range paths {
		if len(v) > 0 {
			pinfo := new(hv.PkgInfo)
			err := q.WhereEqual("import_path", v).Find(pinfo)
			if err == nil {
				pinfos = append(pinfos, pinfo)
			} else {
				pinfos = append(pinfos, &hv.PkgInfo{ImportPath: v})
			}
		}
	}
	return pinfos
}
開發者ID:CharlesSong,項目名稱:gowalker,代碼行數:15,代碼來源:packages.go

示例14: getGroupPkgInfoByIdWithQ

func getGroupPkgInfoByIdWithQ(q *qbs.Qbs, pids []string) []*hv.PkgInfo {
	pinfos := make([]*hv.PkgInfo, 0, len(pids))
	for _, v := range pids {
		pid, _ := strconv.ParseInt(v, 10, 64)
		if pid > 0 {
			pinfo := new(hv.PkgInfo)
			err := q.WhereEqual("id", pid).Find(pinfo)
			if err == nil {
				pinfos = append(pinfos, pinfo)
			} else {
				beego.Trace("models.GetGroupPkgInfoById ->", err)
			}
		}
	}
	return pinfos
}
開發者ID:CharlesSong,項目名稱:gowalker,代碼行數:16,代碼來源:packages.go

示例15: calRefRanks

func calRefRanks(q *qbs.Qbs, refPids []string) int64 {
	refRank := 0
	for _, spid := range refPids {
		pid, _ := strconv.Atoi(spid)
		if pid == 0 {
			continue
		}
		info := new(hv.PkgInfo)
		err := q.WhereEqual("id", pid).Find(info)
		if err == nil {
			refRank += int(info.Rank) * 10 / 100
		} else {
			beego.Trace("models.calRefRanks ->", err)
		}
	}
	return int64(refRank)
}
開發者ID:CharlesSong,項目名稱:gowalker,代碼行數:17,代碼來源:projects.go


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