当前位置: 首页>>代码示例>>Golang>>正文


Golang Qbs.WhereEqual方法代码示例

本文整理汇总了Golang中github.com/coocood/qbs.Qbs.WhereEqual方法的典型用法代码示例。如果您正苦于以下问题:Golang Qbs.WhereEqual方法的具体用法?Golang Qbs.WhereEqual怎么用?Golang Qbs.WhereEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/coocood/qbs.Qbs的用法示例。


在下文中一共展示了Qbs.WhereEqual方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: 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--
			_, err = q.Save(info)
			if err != nil {
				beego.Error("models.updateImportInfo(): delete:", path, err)
			}
		}
	}

	// Error means this project does not exist, simply skip.
}
开发者ID:richardjoo,项目名称:gowalker,代码行数:27,代码来源:models.go

示例2: GetEpisodes

//分页查询
func GetEpisodes(q *qbs.Qbs, page int, column string, value interface{}, order string, url string) ([]*Episode, *Pagination) {
	page -= 1
	if page < 0 {
		page = 0
	}

	var episode []*Episode
	var rows int64
	if column == "" {
		fmt.Println(ItemsPerPage)
		fmt.Println(page)
		rows = q.Count("episode")
		err := q.OrderByDesc(order).
			Limit(ItemsPerPage).Offset(page * ItemsPerPage).FindAll(&episode)
		if err != nil {
			fmt.Println(err)
		}
	} else {
		rows = q.WhereEqual(column, value).Count("episode")
		err := q.WhereEqual(column, value).OrderByDesc(order).
			Limit(ItemsPerPage).Offset(page * ItemsPerPage).FindAll(&episode)
		if err != nil {
			fmt.Println(err)
		}
	}
	fmt.Println(episode)
	url = url[:strings.Index(url, "=")+1]
	pagination := NewPagination(page, int(rows), url)

	return episode, pagination
}
开发者ID:river-lee,项目名称:qishare,代码行数:32,代码来源:episode.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: getPkgInfoWithQ

func getPkgInfoWithQ(path, tag string, q *qbs.Qbs) (*hv.PkgInfo, error) {
	// Check path length to reduce connect times.
	if len(path) == 0 {
		return nil, errors.New("models.getPkgInfoWithQ -> Empty path as not found.")
	}

	pinfo := new(hv.PkgInfo)
	q.WhereEqual("import_path", path).Find(pinfo)

	proPath := utils.GetProjectPath(path)
	if utils.IsGoRepoPath(path) {
		proPath = "code.google.com/p/go"
	}
	beego.Trace("models.getPkgInfoWithQ -> proPath:", proPath)
	ptag := new(PkgTag)
	cond := qbs.NewCondition("path = ?", proPath).And("tag = ?", tag)
	err := q.Condition(cond).Find(ptag)
	if err != nil {
		pinfo.Ptag = "ptag"
		return pinfo, errors.New(
			fmt.Sprintf("models.getPkgInfoWithQ( %s:%s ) -> 'PkgTag': %s", path, tag, err))
	}
	pinfo.Vcs = ptag.Vcs
	pinfo.Tags = ptag.Tags

	// Only 'PkgInfo' cannot prove that package exists,
	// we have to check 'PkgDecl' as well in case it was deleted by mistake.

	pdecl := new(PkgDecl)
	cond = qbs.NewCondition("pid = ?", pinfo.Id).And("tag = ?", tag)
	err = q.Condition(cond).Find(pdecl)
	if err != nil {
		// Basically, error means not found, so we set 'pinfo.PkgVer' to 0
		// because server uses it to decide whether force update.
		pinfo.PkgVer = 0
		pinfo.Ptag = "ptag"
		return pinfo, errors.New(
			fmt.Sprintf("models.getPkgInfoWithQ( %s:%s ) -> 'PkgDecl': %s", path, tag, err))
	}

	docPath := path + utils.TagSuffix("-", tag)
	if !com.IsExist("." + utils.DocsJsPath + docPath + ".js") {
		pinfo.PkgVer = 0
		pinfo.Ptag = "ptag"
		return pinfo, errors.New(
			fmt.Sprintf("models.getPkgInfoWithQ( %s:%s ) -> JS: File not found", path, tag))
	}

	return pinfo, nil
}
开发者ID:CharlesSong,项目名称:gowalker,代码行数:50,代码来源:packages.go

示例5: 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

示例6: 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

示例7: 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

示例8: FindUserByName

func FindUserByName(q *qbs.Qbs, n string) (*User, error) {
	user := new(User)
	err := q.WhereEqual("name", n).Find(user)
	return user, err
}
开发者ID:nonempty,项目名称:qbs,代码行数:5,代码来源:example.go

示例9: findPersonByUserId

/*
* 通过用户编号获得人员信息
* @param  userId 用户编号
* @return person
 */
func (p *Person) findPersonByUserId(userId string, q *qbs.Qbs) *Person {
	person := new(Person)
	q.WhereEqual("user_id", userId).Find(person)
	return person
}
开发者ID:river-lee,项目名称:qishare,代码行数:10,代码来源:person.go

示例10: FindUserByCode

//查询验证码是否存在
func FindUserByCode(q *qbs.Qbs, code string) *models.User {
	user := new(models.User)
	q.WhereEqual("validate_code", code).Find(user)
	return user
}
开发者ID:river-lee,项目名称:qishare,代码行数:6,代码来源:UserController.go

示例11: FindUserById

func FindUserById(q *qbs.Qbs, id int64) *models.User {
	user := new(models.User)
	q.WhereEqual("id", id).Find(user)
	return user
}
开发者ID:river-lee,项目名称:qishare,代码行数:5,代码来源:UserController.go

示例12: HasEmail

func (u *User) HasEmail(q *qbs.Qbs) bool {
	user := new(User)
	q.WhereEqual("email", u.Email).Find(user)

	return user.Id > 0
}
开发者ID:river-lee,项目名称:qishare,代码行数:6,代码来源:user.go

示例13: updateImportInfo

func updateImportInfo(q *qbs.Qbs, path string, pid, rank int, add bool) {
	spid := strconv.Itoa(pid)

	// Save package information.
	info := new(hv.PkgInfo)
	err := q.WhereEqual("import_path", path).Find(info)
	if err == nil {
		// Check if pid exists in this project.
		refPids := strings.Split(info.RefPids, "|")
		i := getRefIndex(refPids, spid)

		if add {
			// Add operation.
			if i == -1 {
				refPids = append(refPids, spid)
				i = len(refPids) - 1
			}

			info.RefPids = strings.Join(refPids, "|")
			info.RefNum = len(refPids)
			if info.RefNum > 0 && strings.HasPrefix(info.RefPids, "|") {
				info.RefPids = info.RefPids[1:]
				info.RefNum--
			}

			_, err = q.Save(info)
			if err != nil {
				beego.Error("models.updateImportInfo -> add:", path, err)
			}

		} else if i > -1 {
			// Delete operation
			refPids = append(refPids[:i], refPids[i+1:]...)

			info.RefPids = strings.Join(refPids, "|")
			info.RefNum = len(refPids)
			if info.RefNum > 0 && strings.HasPrefix(info.RefPids, "|") {
				info.RefPids = info.RefPids[1:]
				info.RefNum--
			}

			_, err = q.Save(info)
			if err != nil {
				beego.Error("models.updateImportInfo -> delete:", path, err)
			}
		}
		return
	}

	if add {
		// Record imports.
		pimp := new(PkgImport)
		q.WhereEqual("path", path).Find(pimp)
		pimp.Path = path
		pimps := strings.Split(pimp.Imports, "|")
		i := getRefIndex(pimps, spid)
		if i == -1 {
			pimps = append(pimps, spid)
			pimp.Imports = strings.Join(pimps, "|")
			_, err = q.Save(pimp)
			if err != nil {
				beego.Error("models.updateImportInfo -> record import:", path, err)
			}
		}
	}
}
开发者ID:CharlesSong,项目名称:gowalker,代码行数:66,代码来源:projects.go

示例14: FindNaById

func FindNaById(q *qbs.Qbs, id int64) (*Topic, error) {
	na := new(Topic)
	//na.Id = id
	err := q.WhereEqual("id", id).Find(na)
	return na, err
}
开发者ID:rose312,项目名称:mzr,代码行数:6,代码来源:t2.go


注:本文中的github.com/coocood/qbs.Qbs.WhereEqual方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。