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

Golang gorethink.Desc函数代码示例

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

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



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

示例1: baseFind

func baseFind(o Option) r.Term {
	q := r.Table(resourceName)

	// slicing
	if o.Slice != "" {
		slice := strings.Split(o.Slice, ",")
		start, _ := strconv.Atoi(slice[0])
		end, _ := strconv.Atoi(slice[1])
		q = q.Slice(start, end)
	}

	// ordering
	if o.Order != "" {
		order := strings.Split(strings.ToLower(o.Order), ",")
		if len(order) == 2 && order[1] == "desc" {
			q = q.OrderBy(r.Desc(order[0]))
		} else {
			q = q.OrderBy(order[0])
		}
	}

	// filtering
	q = q.Filter(o.Filter)

	return q
}
开发者ID:javinc,项目名称:puto,代码行数:26,代码来源:resource.go


示例2: addOptions

func addOptions(q rdb.Term, value string, index string, opts *t.BrowseOpt) rdb.Term {
	var limit uint = 1024 // TODO(gene): pass into adapter as a config param
	var lower, upper interface{}

	if opts != nil {
		if opts.Since > 0 {
			lower = opts.Since
		} else {
			lower = rdb.MinVal
		}

		if opts.Before > 0 {
			upper = opts.Before
		} else {
			upper = rdb.MaxVal
		}

		if value != "" {
			lower = []interface{}{value, lower}
			upper = []interface{}{value, upper}
		}

		if opts.Limit > 0 && opts.Limit < limit {
			limit = opts.Limit
		}
	} else {
		lower = []interface{}{value, rdb.MinVal}
		upper = []interface{}{value, rdb.MaxVal}
	}

	return q.Between(lower, upper, rdb.BetweenOpts{Index: index}).
		OrderBy(rdb.OrderByOpts{Index: rdb.Desc(index)}).Limit(limit)
}
开发者ID:ycaihua,项目名称:chat,代码行数:33,代码来源:adapter.go


示例3: loadLatestSales

func loadLatestSales(websocketConnection *websocket.Conn) {
	results, err := r.Table("analytics").Filter(M{
		"type": "sale",
	}).OrderBy(
		r.Desc(r.Row.Field("data").Field("date")),
	).Limit(10).Map(func(row r.Term) interface{} {
		return row.Field("data")
	}).Run(rethinkSession)
	if err != nil {
		log.Printf("error loadLatestSales: %q", err)
	}
	defer results.Close()

	var latestSales []interface{}
	err = results.All(&latestSales)
	if err != nil {
		log.Println(err)
		return
	}

	log.Printf("sending latest %d sales\n", len(latestSales))

	socketOutgoingMessage := &SocketOutgoingMessage{
		Function: "loadLatestSales",
		Data: M{
			"type": "sale",
			"data": latestSales,
		},
	}

	err = websocketConnection.WriteJSON(socketOutgoingMessage)
	if err != nil {
		log.Println(err)
	}
}
开发者ID:gagliardetto,项目名称:RethinkDB-Golang-dashboard,代码行数:35,代码来源:analytics.go


示例4: Slot

func Slot(r Repository) (*db.Cursor, error) {
	return db.Table(r.Table()).
		Filter(db.Row.Field("slot").Gt(0)).
		OrderBy(db.Desc("slot")).
		Pluck("id", "name", "slot").
		Run(r.Session())
}
开发者ID:mishalzaman,项目名称:zing,代码行数:7,代码来源:dat.go


示例5: GetAllArticlesInBlog

func (r *repo) GetAllArticlesInBlog(blog *blogalert.Blog) ([]*blogalert.Article, error) {
	if blog == nil {
		return nil, nil
	}

	cursor, err := gorethink.DB(Database).Table(ArticleTable).
		OrderBy(gorethink.Desc("ts")).
		Filter(gorethink.Row.Field("blog").Eq(blog.URL.String())).
		Limit(100).
		Run(r.session)

	if err != nil {
		return nil, err
	}

	a := []*article{}

	err = cursor.All(&a)
	if err != nil {
		return nil, err
	}

	articles := make([]*blogalert.Article, 0, len(a))

	for _, v := range a {
		if article, err := v.ToArticle(blog); err == nil {
			articles = append(articles, article)
			r.cache.SetArticle(article)
		}
	}

	return articles, nil
}
开发者ID:gophergala2016,项目名称:blogalert,代码行数:33,代码来源:repo.go


示例6: GetUserArticlesRead

func (r *repo) GetUserArticlesRead(UID string, blog *blogalert.Blog) ([]*blogalert.Article, error) {
	if blog == nil {
		return nil, nil
	}

	cursor, err := gorethink.DB(Database).Table(ArticleReadTable).
		OrderBy(gorethink.Desc("ts")).
		Filter(gorethink.Row.Field("uid").Eq(UID)).
		Filter(gorethink.Row.Field("blog").Eq(blog.URL.String())).
		Limit(100).
		Run(r.session)
	if err != nil {
		return nil, err
	}

	a := []*articleRead{}

	err = cursor.All(&a)
	if err != nil {
		return nil, err
	}

	articles := make([]*blogalert.Article, 0, len(a))

	for _, v := range a {
		if article, err := r.GetArticle(v.ArticleURL); err == nil {
			articles = append(articles, article)
		}
	}

	return articles, nil
}
开发者ID:gophergala2016,项目名称:blogalert,代码行数:32,代码来源:repo.go


示例7: List

func List(r Repository, nameField string, offset int, limit int) (*db.Cursor, error) {
	return db.Table(r.Table()).
		OrderBy(db.OrderByOpts{Index: db.Desc("id")}).
		Slice(offset, limit).
		Pluck("id", nameField).
		Run(r.Session())
}
开发者ID:mishalzaman,项目名称:zing,代码行数:7,代码来源:dat.go


示例8: subscribeChannelMessage

func subscribeChannelMessage(client *Client, data interface{}) {
	go func() {
		eventData := data.(map[string]interface{})
		val, ok := eventData["channelId"]
		if !ok {
			return
		}
		channelId, ok := val.(string)
		if !ok {
			return
		}
		stop := client.NewStopChannel(MessageStop)
		cursor, err := r.Table("message").
			OrderBy(r.OrderByOpts{Index: r.Desc("createdAt")}).
			Filter(r.Row.Field("channelId").Eq(channelId)).
			Changes(r.ChangesOpts{IncludeInitial: true}).
			Run(client.session)

		if err != nil {
			client.send <- Message{"error", err.Error()}
			return
		}
		changeFeedHelper(cursor, "message", client.send, stop)
	}()
}
开发者ID:knowthen,项目名称:rtsupportserver,代码行数:25,代码来源:handlers.go


示例9: Events

func (m *Manager) Events(limit int) ([]*shipyard.Event, error) {
	res, err := r.Table(tblNameEvents).OrderBy(r.Desc("Time")).Limit(limit).Run(m.session)
	if err != nil {
		return nil, err
	}
	var events []*shipyard.Event
	if err := res.All(&events); err != nil {
		return nil, err
	}
	return events, nil
}
开发者ID:atassumer,项目名称:shipyard,代码行数:11,代码来源:manager.go


示例10: main

func main() {
	log.Println("VERSION: ", VERSION)
	e := echo.New()
	e.Use(middleware.Logger())
	e.Use(middleware.Recover())
	e.Use(cors.Default().Handler)
	e.Index("public/index.html")
	e.Static("/", "public")

	if len(os.Args) < 2 {
		fmt.Println("\nPlease input callback url.\n  Usage: app.exe [callback_url]")
		os.Exit(0)
	}
	callback_url = os.Args[1]
	//e.Favicon("public/favicon.ico")

	server, err := socketio.NewServer(nil)
	if err != nil {
		log.Fatal(err)
	}
	e.Get("/publish/photo", CallbackHandler)
	e.Post("/publish/photo", ReceiveHandler)
	e.Get("/socket.io/", server)

	server.On("connection", func(so socketio.Socket) {
		log.Println("====================== on connection ======================")
		result := make([]interface{}, 12)
		cur, err := r.Table("instacat").OrderBy(r.OrderByOpts{
			Index: r.Desc("time"),
		}).Limit(12).Run(session)
		if err != nil {
			log.Println(err.Error())
		}
		cur.All(&result)
		fmt.Println("Get result over. ")
		err = so.Emit("recent", result)
		if err != nil {
			log.Println(err.Error())
		}
		so.On("disconnect", func() {
			log.Println("on disconnect")
		})

		RealtimeChangefeed(so)
	})

	//go SubscribeTag()
	go sub()
	port := ":3000"
	log.Printf("Starting HTTP service on %s ...", port)
	e.Run(port)

}
开发者ID:jimmyplaza,项目名称:RethinkDB-Instagram,代码行数:53,代码来源:main.go


示例11: Events

func (m DefaultManager) Events(limit int) ([]*shipyard.Event, error) {
	t := r.Table(tblNameEvents).OrderBy(r.Desc("Time"))
	if limit > -1 {
		t.Limit(limit)
	}
	res, err := t.Run(m.session)
	if err != nil {
		return nil, err
	}
	events := []*shipyard.Event{}
	if err := res.All(&events); err != nil {
		return nil, err
	}
	return events, nil
}
开发者ID:nfoonf,项目名称:shipyard,代码行数:15,代码来源:manager.go


示例12: GetLatestQuote

func (s *Storage) GetLatestQuote() Quote {

	rows, err := r.Table("quotes").OrderBy(r.Desc("timestamp")).Run(s.Session)
	if err != nil {
		fmt.Println(err)
	}
	defer rows.Close()

	var quote Quote
	err2 := rows.One(&quote)
	if err2 != nil {
		fmt.Println(err2)
	}

	fmt.Printf("Fetch one record %#v\n", quote)

	return quote
}
开发者ID:wvdeutekom,项目名称:GoQuotes,代码行数:18,代码来源:quote.go


示例13: GetPipelineRunStatusLatest

func (c *rethinkClient) GetPipelineRunStatusLatest(id string) (*pps.PipelineRunStatus, error) {
	cursor, err := c.statuses.
		GetAllByIndex("pipeline_run_id", id).
		OrderBy(gorethink.Desc("timestamp")).
		Nth(0).
		ToJSON().
		Run(c.session)
	if err != nil {
		return nil, err
	}
	data := ""
	if !cursor.Next(&data) {
		return nil, cursor.Err()
	}
	var pipelineRunStatus pps.PipelineRunStatus
	if err := jsonpb.UnmarshalString(data, &pipelineRunStatus); err != nil {
		return nil, err
	}
	return &pipelineRunStatus, nil
}
开发者ID:henrylee2cn,项目名称:pachyderm,代码行数:20,代码来源:rethink_client.go


示例14: ListPipelineInfos

func (a *rethinkAPIServer) ListPipelineInfos(ctx context.Context, request *google_protobuf.Empty) (response *persist.PipelineInfos, err error) {
	defer func(start time.Time) { a.Log(request, response, err, time.Since(start)) }(time.Now())
	pipelineInfoObjs, err := a.getAllMessages(
		pipelineInfosTable,
		func() proto.Message { return &persist.PipelineInfo{} },
		func(term gorethink.Term) gorethink.Term {
			return term.OrderBy(gorethink.Desc("created_at"))
		},
	)
	if err != nil {
		return nil, err
	}
	pipelineInfos := make([]*persist.PipelineInfo, len(pipelineInfoObjs))
	for i, pipelineInfoObj := range pipelineInfoObjs {
		pipelineInfos[i] = pipelineInfoObj.(*persist.PipelineInfo)
	}
	return &persist.PipelineInfos{
		PipelineInfo: pipelineInfos,
	}, nil
}
开发者ID:mehulsbhatt,项目名称:pachyderm,代码行数:20,代码来源:rethink_api_server.go


示例15: GetBookmarks

func (c *Connection) GetBookmarks(userID string, page int64) ([]Bookmark, error) {
	var bookmarks []Bookmark

	cursor, err := r.DB("magnet").
		Table("bookmarks").
		OrderBy(r.OrderByOpts{r.Desc("Created")}).
		Filter(r.Row.Field("User").Eq(userID)).
		Skip(50 * page).
		Limit(50).
		Run(c.session)

	if err != nil {
		log.Print(err)
		return bookmarks, err
	}

	cursor.All(&bookmarks)
	cursor.Close()
	return bookmarks, err
}
开发者ID:gauthierc,项目名称:magnet,代码行数:20,代码来源:data.go


示例16: GetAllPipelineRunStatuses

func (c *rethinkClient) GetAllPipelineRunStatuses(pipelineRunID string) ([]*pps.PipelineRunStatus, error) {
	cursor, err := c.pipelineRunStatuses.
		GetAllByIndex("pipeline_run_id", pipelineRunID).
		OrderBy(gorethink.Desc("timestamp")).
		Without("id").
		Map(rethinkToJSON).
		Run(c.session)
	if err != nil {
		return nil, err
	}
	var pipelineRunStatuses []*pps.PipelineRunStatus
	data := ""
	for cursor.Next(&data) {
		var pipelineRunStatus pps.PipelineRunStatus
		if err := jsonpb.UnmarshalString(data, &pipelineRunStatus); err != nil {
			return nil, err
		}
		pipelineRunStatuses = append(pipelineRunStatuses, &pipelineRunStatus)
	}
	return pipelineRunStatuses, cursor.Err()
}
开发者ID:sr,项目名称:pachyderm,代码行数:21,代码来源:rethink_client.go


示例17: orders

func orders(w http.ResponseWriter, q *http.Request) {
	ctx, err := NewContext(q)
	if err != nil {
		log.Println(err)
	}

	rows, err := r.Db("goShop").Table("orders").OrderBy(r.Desc("Date")).Run(ctx.Db)

	if err != nil {
		log.Println(err)
	}
	var t []Order
	err = rows.All(&t)
	if err != nil {
		log.Println(err)
	}

	newmap := map[string]interface{}{"Orders": t}

	templatesA.ExecuteTemplate(w, "orders", newmap)

}
开发者ID:ivansyi,项目名称:goShop,代码行数:22,代码来源:app.go


示例18: GetJobInfosByPipeline

func (a *rethinkAPIServer) GetJobInfosByPipeline(ctx context.Context, request *pps.Pipeline) (response *persist.JobInfos, err error) {
	defer func(start time.Time) { a.Log(request, response, err, time.Since(start)) }(time.Now())
	jobInfoObjs, err := a.getMessagesByIndex(
		jobInfosTable,
		pipelineNameIndex,
		request.Name,
		func() proto.Message { return &persist.JobInfo{} },
		func(term gorethink.Term) gorethink.Term {
			return term.OrderBy(gorethink.Desc("created_at"))
		},
	)
	if err != nil {
		return nil, err
	}
	jobInfos := make([]*persist.JobInfo, len(jobInfoObjs))
	for i, jobInfoObj := range jobInfoObjs {
		jobInfos[i] = jobInfoObj.(*persist.JobInfo)
	}
	return &persist.JobInfos{
		JobInfo: jobInfos,
	}, nil
}
开发者ID:mehulsbhatt,项目名称:pachyderm,代码行数:22,代码来源:rethink_api_server.go


示例19: GetJobLogs

// ordered by time, latest to earliest
func (a *rethinkAPIServer) GetJobLogs(ctx context.Context, request *pps.Job) (response *persist.JobLogs, err error) {
	defer func(start time.Time) { a.Log(request, response, err, time.Since(start)) }(time.Now())
	jobLogObjs, err := a.getMessagesByIndex(
		jobLogsTable,
		jobIDIndex,
		request.Id,
		func() proto.Message { return &persist.JobLog{} },
		func(term gorethink.Term) gorethink.Term {
			return term.OrderBy(gorethink.Desc("timestamp"))
		},
	)
	if err != nil {
		return nil, err
	}
	jobLogs := make([]*persist.JobLog, len(jobLogObjs))
	for i, jobLogObj := range jobLogObjs {
		jobLogs[i] = jobLogObj.(*persist.JobLog)
	}
	return &persist.JobLogs{
		JobLog: jobLogs,
	}, nil
}
开发者ID:mehulsbhatt,项目名称:pachyderm,代码行数:23,代码来源:rethink_api_server.go


示例20: Search

func (c *Connection) Search(userID string, params martini.Params, query string) ([]interface{}, error) {
	var response []interface{}
	page, _ := strconv.ParseInt(params["page"], 10, 16)

	cursor, err := r.DB("magnet").
		Table("bookmarks").
		OrderBy(r.OrderByOpts{r.Desc("Created")}).
		Filter(r.Row.Field("Title").Match("(?i)" + query).
			And(r.Row.Field("User").Eq(userID))).
		Skip(50 * page).
		Limit(50).
		Run(c.session)

	if err != nil {
		log.Print(err)
		return nil, err
	}

	cursor.All(&response)
	cursor.Close()
	return response, err
}
开发者ID:gauthierc,项目名称:magnet,代码行数:22,代码来源:data.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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