本文整理汇总了Golang中github.com/astaxie/beego/orm.QueryTable函数的典型用法代码示例。如果您正苦于以下问题:Golang QueryTable函数的具体用法?Golang QueryTable怎么用?Golang QueryTable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QueryTable函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: AllCategories
// query all
func AllCategories(orderBy bool) ([]*Category, error) {
orm := orm.NewOrm()
categories := make([]*Category, 0)
var err error
if orderBy {
_, err = orm.QueryTable("category").OrderBy("-createTime").All(&categories)
} else {
_, err = orm.QueryTable("category").All(&categories)
}
return categories, err
}
开发者ID:zhao-l-c,项目名称:goblog,代码行数:12,代码来源:categoryModel.go
示例2: GetUserProfile
func GetUserProfile(id int64) (*UserProfile, error) {
orm := GetOrm()
user := new(User)
if err := orm.QueryTable("user").Filter("id", id).One(user, "UserProfile"); err != nil {
return nil, err
}
profile := new(UserProfile)
if err := orm.QueryTable("user_profile").Filter("id", user.UserProfile.Id).One(profile); err != nil {
return nil, err
}
return profile, nil
}
开发者ID:endville,项目名称:gpsapi,代码行数:12,代码来源:user.go
示例3: GetTerminalProfile
func GetTerminalProfile(id int64) (*TerminalProfile, error) {
orm := GetOrm()
terminal := new(Terminal)
if err := orm.QueryTable("terminal").Filter("id", id).One(terminal, "TerminalProfile"); err != nil {
return nil, err
}
profile := new(TerminalProfile)
if err := orm.QueryTable("terminal_profile").Filter("id", terminal.TerminalProfile.Id).One(profile); err != nil {
return nil, err
}
return profile, nil
}
开发者ID:endville,项目名称:gpsapi,代码行数:12,代码来源:terminal.go
示例4: GetTerminalCarrier
func GetTerminalCarrier(id int64) (*TerminalCarrier, error) {
orm := GetOrm()
terminal := new(Terminal)
if err := orm.QueryTable("terminal").Filter("id", id).One(terminal, "TerminalProfile"); err != nil {
return nil, err
}
carrier := new(TerminalCarrier)
if err := orm.QueryTable("terminal_carrier").Filter("id", terminal.TerminalProfile.Id).One(carrier); err != nil {
return nil, err
}
return carrier, nil
}
开发者ID:endville,项目名称:gpsapi,代码行数:12,代码来源:terminal.go
示例5: GetAllTerminals
func GetAllTerminals(cond *orm.Condition, pageIndex, pageSize int, order ...string) (*[]Terminal, int64, error) {
orm := GetOrm()
var terminals *[]Terminal = new([]Terminal)
total, err := orm.QueryTable("terminal").SetCond(cond).Count()
if err != nil {
return nil, 0, err
}
_, err = orm.QueryTable("terminal").SetCond(cond).Limit(pageSize, (pageIndex-1)*pageSize).OrderBy(order...).All(terminals)
if err != nil {
return nil, 0, err
}
return terminals, total, nil
}
开发者ID:endville,项目名称:gpsapi,代码行数:13,代码来源:terminal.go
示例6: GetAllRights
func GetAllRights(cond *orm.Condition, pageIndex, pageSize int, order ...string) (*[]Right, int64, error) {
orm := GetOrm()
var roles *[]Right = new([]Right)
total, err := orm.QueryTable("right").SetCond(cond).Count()
if err != nil {
return nil, 0, err
}
_, err = orm.QueryTable("right").SetCond(cond).Limit(pageSize, (pageIndex-1)*pageSize).OrderBy(order...).All(roles)
if err != nil {
return nil, 0, err
}
return roles, total, nil
}
开发者ID:endville,项目名称:gpsapi,代码行数:13,代码来源:right.go
示例7: GetAllMessages
func GetAllMessages(cond *orm.Condition, pageIndex, pageSize int, order ...string) (*[]Message, int64, error) {
orm := GetOrm()
var messages *[]Message = new([]Message)
total, err := orm.QueryTable("message").SetCond(cond).Count()
if err != nil {
return nil, 0, err
}
_, err = orm.QueryTable("message").SetCond(cond).Limit(pageSize, (pageIndex-1)*pageSize).OrderBy(order...).All(messages)
if err != nil {
return nil, 0, err
}
return messages, total, nil
}
开发者ID:endville,项目名称:gpsapi,代码行数:13,代码来源:message.go
示例8: GetAllLogs
func GetAllLogs(cond *orm.Condition, pageIndex, pageSize int, order ...string) (*[]Log, int64, error) {
orm := GetOrm()
var logs *[]Log = new([]Log)
total, err := orm.QueryTable("log").SetCond(cond).Count()
if err != nil {
return nil, 0, err
}
_, err = orm.QueryTable("log").SetCond(cond).Limit(pageSize, (pageIndex-1)*pageSize).OrderBy(order...).All(logs)
if err != nil {
return nil, 0, err
}
return logs, total, nil
}
开发者ID:endville,项目名称:gpsapi,代码行数:13,代码来源:log.go
示例9: GetAllUsers
func GetAllUsers(cond *orm.Condition, pageIndex, pageSize int, order ...string) (*[]User, int64, error) {
orm := GetOrm()
var users *[]User = new([]User)
total, err := orm.QueryTable("user").SetCond(cond).Count()
if err != nil {
return nil, 0, err
}
_, err = orm.QueryTable("user").SetCond(cond).Limit(pageSize, (pageIndex-1)*pageSize).OrderBy(order...).All(users)
if err != nil {
return nil, 0, err
}
return users, total, nil
}
开发者ID:endville,项目名称:gpsapi,代码行数:13,代码来源:user.go
示例10: Articles
func Articles(page int) ([]entities.Article, error) {
var err error
var articles []entities.Article
orm := orm.NewOrm()
_, err = orm.QueryTable("article").All(&articles, "id", "user_id", "title", "tag", "content", "created_at", "updated_at")
return articles, err
}
开发者ID:trigrass2,项目名称:beego_study,代码行数:7,代码来源:article_service.go
示例11: LastArticle
func LastArticle() (entities.Article, error) {
var err error
var article entities.Article
orm := orm.NewOrm()
err = orm.QueryTable("article").OrderBy("-id").One(&article, "id", "user_id", "title", "tag", "content", "created_at", "updated_at")
return article, err
}
开发者ID:trigrass2,项目名称:beego_study,代码行数:7,代码来源:article_service.go
示例12: DeleteComment
func DeleteComment(cid, tid string) error {
commentId, err := strconv.ParseInt(cid, 10, 64)
if err != nil {
return err
}
orm := orm.NewOrm()
comment := &Comment{Id: commentId}
_, err = orm.Delete(comment)
if err != nil {
return err
}
topicId, err := strconv.ParseInt(tid, 10, 64)
if err != nil {
return err
}
comments := make([]*Comment, 0)
_, err = orm.QueryTable("comment").Filter("tid", topicId).OrderBy("-replyTime").All(&comments)
if err != nil {
return err
}
topic := &Topic{Id: topicId}
if orm.Read(topic) == nil && len(comments) > 0 {
topic.ReplyCount--
topic.LastReplyTime = comments[0].ReplyTime
// TODO set last user id
// topic.ReplyLastUserId = comments[0].UserId
orm.Update(topic)
}
return err
}
开发者ID:zhao-l-c,项目名称:goblog,代码行数:30,代码来源:commentModel.go
示例13: GetUser
func GetUser(id int64) (*User, error) {
orm := GetOrm()
user := new(User)
if err := orm.QueryTable("user").Filter("id", id).RelatedSel().One(user); err != nil {
return nil, err
}
return user, nil
}
开发者ID:endville,项目名称:gpsapi,代码行数:8,代码来源:user.go
示例14: FundUser
func FundUser(name string, password string) (entities.User, error) {
var err error
var user entities.User
orm := orm.NewOrm()
err = orm.QueryTable("user").Filter("name", name).Filter("password", password).One(&user, "id", "name", "nick", "password", "age", "cell", "mail", "sex", "CreatedAt", "UpdatedAt")
return user, err
}
开发者ID:trigrass2,项目名称:beego_study,代码行数:8,代码来源:user_service.go
示例15: GetLog
func GetLog(id int64) (*Log, error) {
orm := GetOrm()
log := new(Log)
if err := orm.QueryTable("log").Filter("Id", id).RelatedSel().One(log); err != nil {
return nil, err
}
return log, nil
}
开发者ID:endville,项目名称:gpsapi,代码行数:9,代码来源:log.go
示例16: GetTerminal
func GetTerminal(id int64) (*Terminal, error) {
orm := GetOrm()
terminal := new(Terminal)
if err := orm.QueryTable("terminal").Filter("Id", id).RelatedSel().One(terminal); err != nil {
return nil, err
}
return terminal, nil
}
开发者ID:endville,项目名称:gpsapi,代码行数:9,代码来源:terminal.go
示例17: GetMessage
func GetMessage(id int64) (*Message, error) {
orm := GetOrm()
message := new(Message)
if err := orm.QueryTable("message").Filter("Id", id).One(message); err != nil {
return nil, err
}
return message, nil
}
开发者ID:endville,项目名称:gpsapi,代码行数:9,代码来源:message.go
示例18: OpenUser
func OpenUser(openId string, openType int) (*entities.OpenUser, error) {
var err error
var openUser entities.OpenUser
orm := orm.NewOrm()
err = orm.QueryTable("open_user").Filter("open_id", openId).Filter("type", openType).One(&openUser)
return &openUser, err
}
开发者ID:zld406504302,项目名称:beego_study,代码行数:9,代码来源:open_user_service.go
示例19: QueryCommentsByTid
func QueryCommentsByTid(tid string) ([]*Comment, error) {
titleId, err := strconv.ParseInt(tid, 10, 64)
if err != nil {
return nil, err
}
orm := orm.NewOrm()
comments := make([]*Comment, 0)
_, err = orm.QueryTable("comment").Filter("tid", titleId).All(&comments)
return comments, err
}
开发者ID:zhao-l-c,项目名称:goblog,代码行数:10,代码来源:commentModel.go
示例20: DeleteLog
func DeleteLog(id int64) error {
orm := GetOrm()
rows, err := orm.QueryTable("log").Filter("Id", id).Delete()
if err != nil {
return err
}
if rows == 0 {
return ERROR_NOT_FOUND
}
return nil
}
开发者ID:endville,项目名称:gpsapi,代码行数:11,代码来源:log.go
注:本文中的github.com/astaxie/beego/orm.QueryTable函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论