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

Golang gorethink.Asc函数代码示例

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

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



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

示例1: Nodes

// Returns a complete list of all nodes
func (s *HTTPServer) Nodes(w http.ResponseWriter, req *http.Request) {
	instructions := []Machine{}

	// Fetch all the items from the database
	rows, err := r.Table(tableIpxe).OrderBy(r.Asc("Created")).Run(session)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	// Scan each row into a TodoItem instance and then add this to the list
	for rows.Next() {
		var instruction Machine

		err := rows.Scan(&instruction)
		if err != nil {
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}

		instructions = append(instructions, instruction)
	}

	renderHtml(w, "enforcer", instructions)
}
开发者ID:EntropyWorks,项目名称:enforcer,代码行数:26,代码来源:node_endpoint.go


示例2: GetAllTrips

//GetAllTrips returns all Trips for the loged user
func (t *Trips) GetAllTrips(w rest.ResponseWriter, r *rest.Request) {
	trips := []Trip{}

	//table := t.TableName
	// Fetch all the items from the database
	res, err := rethink.Table(tableName).OrderBy(rethink.Asc("Created")).Run(t.Conn)
	if err != nil {
		rest.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	err = res.All(&trips)

	//Include total places in the
	for _, trip := range trips {
		trip.TotalPlaces = len(trip.Places)
	}

	if err != nil {
		rest.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	w.WriteJson(&trips)
	res.Close()
}
开发者ID:yetis-br,项目名称:travelPlanning,代码行数:26,代码来源:trip.go


示例3: Accounts

func (m *Manager) Accounts() ([]*shipyard.Account, error) {
	res, err := r.Table(tblNameAccounts).OrderBy(r.Asc("username")).Run(m.session)
	if err != nil {
		return nil, err
	}
	var accounts []*shipyard.Account
	if err := res.All(&accounts); err != nil {
		return nil, err
	}
	return accounts, nil
}
开发者ID:atassumer,项目名称:shipyard,代码行数:11,代码来源:manager.go


示例4: Roles

func (m *Manager) Roles() ([]*shipyard.Role, error) {
	res, err := r.Table(tblNameRoles).OrderBy(r.Asc("name")).Run(m.session)
	if err != nil {
		return nil, err
	}
	roles := []*shipyard.Role{}
	if err := res.All(&roles); err != nil {
		return nil, err
	}
	return roles, nil
}
开发者ID:rbramwell,项目名称:shipyard,代码行数:11,代码来源:manager.go


示例5: Extensions

func (m *Manager) Extensions() ([]*shipyard.Extension, error) {
	res, err := r.Table(tblNameExtensions).OrderBy(r.Asc("name")).Run(m.session)
	if err != nil {
		return nil, err
	}
	exts := []*shipyard.Extension{}
	if err := res.All(&exts); err != nil {
		return nil, err
	}
	return exts, nil
}
开发者ID:rbramwell,项目名称:shipyard,代码行数:11,代码来源:manager.go


示例6: Accounts

func (m DefaultManager) Accounts() ([]*auth.Account, error) {
	res, err := r.Table(tblNameAccounts).OrderBy(r.Asc("username")).Run(m.session)
	if err != nil {
		return nil, err
	}
	accounts := []*auth.Account{}
	if err := res.All(&accounts); err != nil {
		return nil, err
	}
	return accounts, nil
}
开发者ID:nfoonf,项目名称:shipyard,代码行数:11,代码来源:manager.go


示例7: WebhookKeys

func (m DefaultManager) WebhookKeys() ([]*dockerhub.WebhookKey, error) {
	res, err := r.Table(tblNameWebhookKeys).OrderBy(r.Asc("image")).Run(m.session)
	if err != nil {
		return nil, err
	}
	keys := []*dockerhub.WebhookKey{}
	if err := res.All(&keys); err != nil {
		return nil, err
	}
	return keys, nil
}
开发者ID:nfoonf,项目名称:shipyard,代码行数:11,代码来源:manager.go


示例8: GetTopics

func (s *Rethinkdb) GetTopics() ([]*dialogue.Topic, error) {
	var topics []*dialogue.Topic
	res, err := rdb.Table(TOPIC_TABLE).OrderBy(rdb.Asc("Created")).Run(s.session)
	if err != nil {
		log.Errorf("Unable to get topics from db: %s", err)
		return nil, err
	}
	for res.Next() {
		var t *dialogue.Topic
		if err := res.Scan(&t); err != nil {
			log.Errorf("Unable to deserialize topic from db: %s", err)
			return nil, err
		}
		topics = append(topics, t)
	}
	return topics, nil
}
开发者ID:carriercomm,项目名称:dialogue-1,代码行数:17,代码来源:db.go


示例9: GetPosts

func (s *Rethinkdb) GetPosts(topicId string) ([]*dialogue.Post, error) {
	var posts []*dialogue.Post
	res, err := rdb.Table(POST_TABLE).OrderBy(rdb.Asc("Created")).Run(s.session)
	if err != nil {
		log.Errorf("Unable to get posts from db: %s", err)
		return nil, err
	}
	for res.Next() {
		var p *dialogue.Post
		if err := res.Scan(&p); err != nil {
			log.Errorf("Unable to deserialize post from db: %s", err)
			return nil, err
		}
		posts = append(posts, p)
	}
	return posts, nil
}
开发者ID:carriercomm,项目名称:dialogue-1,代码行数:17,代码来源:db.go


示例10: GetAllPlaces

//GetAllPlaces returns all Places for the loged user
func (t *Places) GetAllPlaces(w rest.ResponseWriter, r *rest.Request) {
	places := []Place{}

	//table := t.TableName
	// Fetch all the items from the database
	res, err := rethink.Table(tableName).OrderBy(rethink.Asc("Created")).Run(t.Conn)
	if err != nil {
		rest.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	err = res.All(&places)
	if err != nil {
		rest.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	w.WriteJson(&places)
	res.Close()
}
开发者ID:yetis-br,项目名称:travelPlanning,代码行数:20,代码来源:place.go


示例11: Run

func (serv *AdjustAllServ) Run(dbSession *r.Session) (err error) {

	// Fetch all the items from the database
	rows, err := r.Table("accounts").OrderBy(r.Asc("CreatedAt")).Run(dbSession)

	for rows.Next() {
		var account models.Account
		err := rows.Scan(&account)
		if err != nil {
			fmt.Println("err", err)
			break
		}
		_, _, err = serv.adjustBalanceServ.Run(dbSession, account)
		if err != nil {
			fmt.Println("err", err)
			break
		}
	}
	return
}
开发者ID:sporto,项目名称:kic,代码行数:20,代码来源:adjust_all.go


示例12: indexHandler

func indexHandler(w http.ResponseWriter, req *http.Request) {
	items := []TodoItem{}

	// Fetch all the items from the database
	res, err := r.Table("items").OrderBy(r.Asc("Created")).Run(session)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	err = res.All(&items)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	renderTemplate(w, "index", map[string]interface{}{
		"Items": items,
		"Route": "all",
	})
}
开发者ID:ramigg,项目名称:GoRethink_TodoDemo,代码行数:21,代码来源:server.go


示例13: subscribeMessage

func subscribeMessage(client *Client, data interface{}) {
	eventData := data.(map[string]interface{})
	val, ok := eventData["channelId"]
	if !ok {
		return
	}
	channelId, ok := val.(string)
	if !ok {
		return
	}
	cursor, err := r.Table("message").
		OrderBy(r.OrderByOpts{Index: r.Asc("createdAt")}).
		Filter(r.Row.Field("channelId").Eq(channelId)).
		Changes(r.ChangesOpts{IncludeInitial: true}).
		Run(client.session)
	if err != nil {
		client.send <- SocketMessage{"error", err.Error()}
		return
	}

	createSubscription(cursor, client, "message", MessageStop)
}
开发者ID:megaserg,项目名称:reactchat,代码行数:22,代码来源:handlers.go


示例14: Registries

func (m DefaultManager) Registries() ([]*shipyard.Registry, error) {
	res, err := r.Table(tblNameRegistries).OrderBy(r.Asc("name")).Run(m.session)
	if err != nil {
		return nil, err
	}

	regs := []*shipyard.Registry{}
	if err := res.All(&regs); err != nil {
		return nil, err
	}

	registries := []*shipyard.Registry{}
	for _, r := range regs {
		reg, err := shipyard.NewRegistry(r.ID, r.Name, r.Addr)
		if err != nil {
			return nil, err
		}

		registries = append(registries, reg)
	}

	return registries, nil
}
开发者ID:nfoonf,项目名称:shipyard,代码行数:23,代码来源:manager.go


示例15: ReadMany

func (c *Accounts) ReadMany(ctx context.Context) (err error) {
	var accounts []models.Account

	rows, err := r.Table("accounts").OrderBy(r.Asc("CreatedAt")).Run(c.DbSession)
	rows.Scan(&accounts)

	for rows.Next() {
		var account models.Account

		err = rows.Scan(&account)
		if err != nil {
			return
		}

		accounts = append(accounts, account)
	}

	if err != nil {
		log.Fatal(err)
		return goweb.Respond.WithStatus(ctx, http.StatusNotFound)
	}
	return goweb.API.RespondWithData(ctx, accounts)
}
开发者ID:sporto,项目名称:kic,代码行数:23,代码来源:accounts.go


示例16: subscribeUser

func subscribeUser(client *Client, data interface{}) {
	var user User
	user.Name = "anonymous"
	client.userName = "anonymous"
	resp, err := r.Table("user").Insert(user).RunWrite(client.session)
	if err != nil {
		client.send <- SocketMessage{"error", err.Error()}
		return
	}
	if len(resp.GeneratedKeys) > 0 {
		client.userId = resp.GeneratedKeys[0]
		fmt.Println("created user id " + client.userId)
	}

	cursor, err := r.Table("user").
		OrderBy(r.OrderByOpts{Index: r.Asc("name")}).
		Changes(r.ChangesOpts{IncludeInitial: true}).
		Run(client.session)
	if err != nil {
		client.send <- SocketMessage{"error", err.Error()}
		return
	}
	createSubscription(cursor, client, "user", UserStop)
}
开发者ID:megaserg,项目名称:reactchat,代码行数:24,代码来源:handlers.go


示例17: List

func (t *ThreadsTable) List(
	owner string,
	sort []string,
	offset int,
	limit int,
	labels []string,
) ([]*models.Thread, error) {

	term := t.GetTable()

	if owner != "" {
		term = t.GetTable().GetAllByIndex("owner", owner)
	}

	// If sort array has contents, parse them and add to the term
	if sort != nil && len(sort) > 0 {
		var conds []interface{}
		for _, cond := range sort {
			if cond[0] == '-' {
				conds = append(conds, gorethink.Desc(cond[1:]))
			} else if cond[0] == '+' || cond[0] == ' ' {
				conds = append(conds, gorethink.Asc(cond[1:]))
			} else {
				conds = append(conds, gorethink.Asc(cond))
			}
		}

		term = term.OrderBy(conds...)
	}

	// Parse labels
	hasLabels := []string{}
	excLabels := []string{}
	for _, label := range labels {
		if label[0] == '-' {
			excLabels = append(excLabels, label[1:])
		} else {
			hasLabels = append(hasLabels, label)
		}
	}

	// Transform that into a term
	if len(hasLabels) > 0 || len(excLabels) > 0 {
		var hasTerm gorethink.Term
		if len(hasLabels) == 1 {
			hasTerm = gorethink.Row.Field("labels").Contains(hasLabels[0])
		} else if len(hasLabels) > 0 {
			for i, label := range hasLabels {
				if i == 0 {
					hasTerm = gorethink.Row.Field("labels").Contains(label)
				} else {
					hasTerm = hasTerm.And(gorethink.Row.Field("labels").Contains(label))
				}
			}
		}

		var excTerm gorethink.Term
		if len(excLabels) == 1 {
			excTerm = gorethink.Not(gorethink.Row.Field("labels").Contains(excLabels[0]))
		} else {
			for i, label := range excLabels {
				if i == 0 {
					excTerm = gorethink.Not(gorethink.Row.Field("labels").Contains(label))
				} else {
					excTerm = excTerm.And(gorethink.Not(gorethink.Row.Field("labels").Contains(label)))
				}
			}
		}

		// Append them into the term
		if len(hasLabels) > 0 && len(excLabels) > 0 {
			term = term.Filter(hasTerm.And(excTerm))
		} else if len(hasLabels) > 0 && len(excLabels) == 0 {
			term = term.Filter(hasTerm)
		} else if len(hasLabels) == 0 && len(excLabels) > 0 {
			term = term.Filter(excTerm)
		}
	}

	// Slice the result
	if offset != 0 || limit != 0 {
		term = term.Slice(offset, offset+limit)
	}

	// Add manifests
	term = term.Map(func(thread gorethink.Term) gorethink.Term {
		return thread.Merge(gorethink.Db(t.GetDBName()).Table("emails").Between([]interface{}{
			thread.Field("id"),
			time.Date(1990, time.January, 1, 23, 0, 0, 0, time.UTC),
		}, []interface{}{
			thread.Field("id"),
			time.Date(2090, time.January, 1, 23, 0, 0, 0, time.UTC),
		}, gorethink.BetweenOpts{
			Index: "threadAndDate",
		}).OrderBy(gorethink.OrderByOpts{Index: "threadAndDate"}).
			Nth(0).Pluck("manifest"))
	})

	// Run the query
	cursor, err := term.Run(t.GetSession())
//.........这里部分代码省略.........
开发者ID:carriercomm,项目名称:lavabot,代码行数:101,代码来源:table_threads.go


示例18: List

func (e *EmailsTable) List(
	owner string,
	sort []string,
	offset int,
	limit int,
	thread string,
) ([]*models.Email, error) {

	filter := map[string]interface{}{}

	if owner != "" {
		filter["owner"] = owner
	}

	if thread != "" {
		filter["thread"] = thread
	}

	term := e.GetTable().Filter(filter).Filter(gorethink.Not(gorethink.Row.Field("status").Eq(gorethink.Expr("queued"))))

	// If sort array has contents, parse them and add to the term
	if sort != nil && len(sort) > 0 {
		var conds []interface{}
		for _, cond := range sort {
			if cond[0] == '-' {
				conds = append(conds, gorethink.Desc(cond[1:]))
			} else if cond[0] == '+' || cond[0] == ' ' {
				conds = append(conds, gorethink.Asc(cond[1:]))
			} else {
				conds = append(conds, gorethink.Asc(cond))
			}
		}

		term = term.OrderBy(conds...)
	}

	// Slice the result in 3 cases
	if offset != 0 && limit == 0 {
		term = term.Skip(offset)
	}

	if offset == 0 && limit != 0 {
		term = term.Limit(limit)
	}

	if offset != 0 && limit != 0 {
		term = term.Slice(offset, offset+limit)
	}

	// Run the query
	cursor, err := term.Run(e.GetSession())
	if err != nil {
		return nil, err
	}
	defer cursor.Close()

	// Fetch the cursor
	var resp []*models.Email
	err = cursor.All(&resp)
	if err != nil {
		return nil, err
	}

	return resp, nil
}
开发者ID:carriercomm,项目名称:api-1,代码行数:65,代码来源:table_emails.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang gorethink.Connect函数代码示例发布时间:2022-05-23
下一篇:
Golang reporter.Reporter类代码示例发布时间: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