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


Golang qbs.GetQbs函數代碼示例

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


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


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