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


Golang Qbs.Condition方法代码示例

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


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

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

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

示例3: main

func main() {
	var (
		q *qbs.Qbs
	)

	q = SetupDb()
	defer q.Close()

	//START SETUP OMIT
	q.Save(&User{
		Id:        1,
		FirstName: "John",
		LastName:  "Doe",
		Age:       24,
	})

	q.Save(&User{
		Id:        2,
		FirstName: "Jane",
		LastName:  "Doe",
		Age:       52,
	})

	q.Save(&User{
		Id:        3,
		FirstName: "Joe",
		LastName:  "Shmoe",
		Age:       10,
	})
	//END SETUP OMIT

	//START CODE OMIT

	var users []*User
	q.Condition(qbs.NewCondition("last_name = ?", "Doe").Or("age < ?", 12)).Limit(2).OrderByDesc("age").FindAll(&users)
	for _, user := range users {
		fmt.Printf("%+v,", user)
	}
	fmt.Println()

	//END CODE OMIT
}
开发者ID:GoSteelProgrammers,项目名称:talk-review-orms,代码行数:42,代码来源:query.go

示例4: checkImport

// checkImport returns true if the package(id) imports given package(path).
func checkImport(q *qbs.Qbs, path string, id int64) bool {
	pinfo := &PkgInfo{
		Id: id,
	}
	err := q.Find(pinfo)
	if err != nil {
		return false
	}

	decl := new(PkgDecl)
	cond := qbs.NewCondition("pid = ?", pinfo.Id).And("tag = ?", "")
	err = q.Condition(cond).Find(decl)
	if err != nil {
		return false
	}

	if strings.Index(decl.Imports, path) == -1 {
		return false
	}

	return true
}
开发者ID:JoeyFan,项目名称:gowalker,代码行数:23,代码来源:projects.go


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