• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang qbs.GetQbs函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: SetupDb

func SetupDb() (q *qbs.Qbs) {
	var (
		err       error
		migration *qbs.Migration
	)

	q, err = qbs.GetQbs()

	if q, err = qbs.GetQbs(); err != nil {
		panic(err)
	}

	if migration, err = qbs.GetMigration(); err != nil {
		panic(err)
	}
	defer migration.Close()

	if err = migration.CreateTableIfNotExists(new(User)); err != nil {
		panic(err)
	}

	if err = migration.CreateTableIfNotExists(new(Profile)); err != nil {
		panic(err)
	}

	return q
}
开发者ID:GoSteelProgrammers,项目名称:talk-review-orms,代码行数:27,代码来源:relationship.go


示例2: Save

func (r *Reply) Save() bool {
	q, err := qbs.GetQbs()
	if err != nil {
		fmt.Println(err)
		return false
	}
	defer q.Close()

	_, err = q.Save(r)
	if err != nil {
		fmt.Println(err)
		return false
	}

	topic := new(Topic)
	topic.Id = r.TopicId
	q.Find(topic)

	if err != nil {
		fmt.Println(err)
		return false
	}

	if topic.Id > 0 {
		topic.Replies += 1
		topic.Save()
	}
	return true
}
开发者ID:jsli,项目名称:gorevel,代码行数:29,代码来源:reply.go


示例3: main2

func main2() {
	qbs.Register("sqlite3", "gowalker.db", "", qbs.NewSqlite3())

	q, _ := qbs.GetQbs()
	defer q.Close()

	pinfo := new(PkgInfo)
	q.Iterate(pinfo, func() error {

		if pinfo.Id > 198 {
			c := &http.Client{}
			req, err := http.NewRequest("GET",
				"http://gowalker.org/add?path="+pinfo.Path+"&views="+fmt.Sprintf("%d", pinfo.Views), nil)
			if err != nil {
				return err
			}
			req.Header.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0")
			resp, err := c.Do(req)
			defer resp.Body.Close()

			fmt.Println(pinfo.Id, pinfo.Path)
			if pinfo.Id >= 10000 {
				return errors.New("FINISH")
			}
		}
		return nil
	})
}
开发者ID:semicarry,项目名称:gowalker,代码行数:28,代码来源:datamg.go


示例4: QbsUpdate

func (c App) QbsUpdate(queries int) revel.Result {
	qbs, _ := qbs.GetQbs()
	defer qbs.Close()

	if queries <= 1 {
		var w World
		w.Id = uint16(rand.Intn(WorldRowCount) + 1)
		if err := qbs.Find(&w); err != nil {
			revel.ERROR.Fatalf("Error scanning world row: %v", err)
		}
		w.RandomNumber = uint16(rand.Intn(WorldRowCount) + 1)
		if _, err := qbs.Save(&w); err != nil {
			revel.ERROR.Fatalf("Error updating world row: %v", err)
		}
		return c.RenderJson(&w)
	}

	ww := make([]World, queries)
	for i := 0; i < queries; i++ {
		ww[i].Id = uint16(rand.Intn(WorldRowCount) + 1)
		if err := qbs.Find(&ww[i]); err != nil {
			revel.ERROR.Fatalf("Error scanning world row: %v", err)
		}
		ww[i].RandomNumber = uint16(rand.Intn(WorldRowCount) + 1)
		if _, err := qbs.Save(&ww[i]); err != nil {
			revel.ERROR.Fatalf("Error scanning world row: %v", err)
		}
	}
	return c.RenderJson(ww)
}
开发者ID:nathana1,项目名称:FrameworkBenchmarks,代码行数:30,代码来源:qbs.go


示例5: GetTopics

func GetTopics(page int, where string, value interface{}, order string, url string) ([]*Topic, *Pagination) {
	q, err := qbs.GetQbs()
	if err != nil {
		fmt.Println(err)
	}
	defer q.Close()

	page -= 1
	if page < 0 {
		page = 0
	}

	var topics []*Topic
	var total int64
	if where == "" {
		total = q.Count("topic")
		err = q.OmitFields("Content").OrderByDesc(order).
			Limit(ItemsPerPage).Offset(page * ItemsPerPage).FindAll(&topics)
	} else {
		total = q.WhereEqual(where, value).Count("topic")
		err = q.WhereEqual(where, value).
			OmitFields("Content").OrderByDesc(order).
			Limit(ItemsPerPage).Offset(page * ItemsPerPage).FindAll(&topics)
	}

	if err != nil {
		fmt.Println(err)
	}

	url = url[:strings.Index(url, "=")+1]
	pagination := NewPagination(page, int(total), url)

	return topics, pagination
}
开发者ID:jsli,项目名称:gorevel,代码行数:34,代码来源:topic.go


示例6: Put

func (this *User) Put(user *models.User) {
	//////////////////
	q, err := qbs.GetQbs()
	assetsError(err)
	defer q.Close()
	//////////////////
	q.Save(user)
}
开发者ID:pa001024,项目名称:MoeFeed,代码行数:8,代码来源:User.go


示例7: Put

func (this *Project) Put(project *models.Project) {
	//////////////////
	q, err := qbs.GetQbs()
	assetsError(err)
	defer q.Close()
	//////////////////
	q.Save(project)
}
开发者ID:pa001024,项目名称:MoeFeed,代码行数:8,代码来源:Project.go


示例8: Begin

//开始连接
func (c *Qbs) Begin() revel.Result {
	q, err := qbs.GetQbs()
	if err != nil {
		fmt.Println(err)
	}
	c.q = q
	return nil
}
开发者ID:river-lee,项目名称:qishare,代码行数:9,代码来源:qbs.go


示例9: getModels

func getModels(items interface{}) (interface{}, error) {
	q, err := qbs.GetQbs()
	if err != nil {
		return nil, err
	}
	defer q.Close()

	err = q.FindAll(items)
	return items, err
}
开发者ID:ktsimpso,项目名称:holla_holla_server,代码行数:10,代码来源:models.go


示例10: NajdiSporocila

func NajdiSporocila(offset int) (error, []*Sporocilo) {
	q, err := qbs.GetQbs()
	if err != nil {
		fmt.Println(err)
		return err, nil
	}
	var sporocila []*Sporocilo
	err2 := q.Limit(25).Offset(offset).FindAll(&sporocila)
	return err2, sporocila
}
开发者ID:ubuntu-si,项目名称:go-ubuntusi-log,代码行数:10,代码来源:sporocilo.go


示例11: Init

func Init() {
	//qbs.RegisterSqlite3("e:/mygo/src/cms/data/orange.db")
	qbs.RegisterSqlite3(utils.Sqlite3Path(beego.AppConfig.String("DatabasePath")))
	db, _ = qbs.GetQbs()
	// //cache期限
	// var err error
	// if expired, err = beego.AppConfig.Int64("CacheExpired"); err != nil {
	// 	expired = 60
	// }
	// bm = cache.NewMemoryCache()
}
开发者ID:jango2015,项目名称:go-cms,代码行数:11,代码来源:init.go


示例12: Fortune

func (c App) Fortune() revel.Result {
	qbs, _ := qbs.GetQbs()
	defer qbs.Close()

	var fortunes []*Fortune
	qbs.FindAll(&fortunes)
	fortunes = append(fortunes,
		&Fortune{Message: "Additional fortune added at request time."})
	sort.Sort(ByMessage{fortunes})
	return c.Render(fortunes)
}
开发者ID:cmsimike,项目名称:FrameworkBenchmarks,代码行数:11,代码来源:app.go


示例13: FindUserByCode

func FindUserByCode(code string) *User {
	q, err := qbs.GetQbs()
	if err != nil {
		fmt.Println(err)
	}
	defer q.Close()

	user := new(User)
	err = q.WhereEqual("validate_code", code).Find(user)

	return user
}
开发者ID:jsli,项目名称:gorevel,代码行数:12,代码来源:user.go


示例14: GetUser

func GetUser(w http.ResponseWriter, r *http.Request) {
	q, err := qbs.GetQbs()
	if err != nil {
		fmt.Println(err)
		w.WriteHeader(500)
		return
	}
	defer q.Close()
	u, err := FindUserById(q, 6)
	data, _ := json.Marshal(u)
	w.Write(data)
}
开发者ID:nonempty,项目名称:qbs,代码行数:12,代码来源:example.go


示例15: FindUserById

func FindUserById(id int64) *User {
	q, err := qbs.GetQbs()
	if err != nil {
		fmt.Println(err)
	}
	defer q.Close()

	user := new(User)
	err = q.WhereEqual("id", id).Find(user)

	return user
}
开发者ID:jsli,项目名称:gorevel,代码行数:12,代码来源:user.go


示例16: ListUser

func (c *Admin) ListUser() revel.Result {
	q, err := qbs.GetQbs()
	if err != nil {
		fmt.Println(err)
	}
	defer q.Close()

	var users []*models.User
	err = q.FindAll(&users)

	return c.Render(users)
}
开发者ID:jsli,项目名称:gorevel,代码行数:12,代码来源:admin.go


示例17: QbsFortune

func (c App) QbsFortune() revel.Result {
	qbs, _ := qbs.GetQbs()
	defer qbs.Close()

	var fortunes []*Fortune
	qbs.FindAll(&fortunes)
	fortunes = append(fortunes,
		&Fortune{Message: "Additional fortune added at request time."})
	sort.Sort(ByMessage{fortunes})
	c.RenderArgs["fortunes"] = fortunes
	return c.RenderTemplate("App/Fortune.html")
}
开发者ID:nathana1,项目名称:FrameworkBenchmarks,代码行数:12,代码来源:qbs.go


示例18: do

func do(w http.ResponseWriter, r *http.Request) {
	q, _ := qbs.GetQbs()
	if q == nil {
		return
	}
	defer q.Close()
	proc := new(Process)
	proc.Id = 100
	proc.Name = "Process"
	q.Save(proc)
	w.Write([]byte("Process"))
}
开发者ID:rose312,项目名称:mzr,代码行数:12,代码来源:k.go


示例19: FindByOwner

// 列出用户所有项目
func (this *Project) FindByOwner(ownerId int64) (obj []*models.Project) {
	//////////////////
	q, err := qbs.GetQbs()
	assetsError(err)
	defer q.Close()
	//////////////////
	err = q.WhereEqual("owner_id", ownerId).OrderByDesc("updated").FindAll(&obj)
	if err != nil {
		return nil
	}
	return
}
开发者ID:pa001024,项目名称:MoeFeed,代码行数:13,代码来源:Project.go


示例20: ListCategory

func (c *Admin) ListCategory() revel.Result {
	q, err := qbs.GetQbs()
	if err != nil {
		fmt.Println(err)
	}
	defer q.Close()

	var categories []*models.Category
	err = q.FindAll(&categories)

	return c.Render(categories)
}
开发者ID:jsli,项目名称:gorevel,代码行数:12,代码来源:admin.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang qbs.NewCondition函数代码示例发布时间:2022-05-23
下一篇:
Golang jas.Context类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap