当前位置: 首页>>代码示例>>Golang>>正文


Golang gorethink.Term类代码示例

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


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

示例1: 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

示例2: Exec

func (this *Instance) Exec(term r.Term) error {
	session, err := this.connect()
	if err != nil {
		return err
	}
	return term.Exec(session)
}
开发者ID:ngthorg,项目名称:grox,代码行数:7,代码来源:rethink.go

示例3: RunWrite

func (this *Instance) RunWrite(term r.Term) (r.WriteResponse, error) {
	session, err := this.connect()
	if err != nil {
		return r.WriteResponse{}, err
	}
	return term.RunWrite(session)
}
开发者ID:ngthorg,项目名称:grox,代码行数:7,代码来源:rethink.go

示例4: Run

func (this *Instance) Run(term r.Term) (*r.Cursor, error) {
	session, err := this.connect()
	if err != nil {
		return nil, err
	}

	return term.Run(session)
}
开发者ID:ngthorg,项目名称:grox,代码行数:8,代码来源:rethink.go

示例5: asyncDatabaseQuery

func asyncDatabaseQuery(client *Client, operation r.Term) {
	go func() {
		err := operation.Exec(client.session)
		if err != nil {
			client.send <- SocketMessage{"error", err.Error()}
		}
	}()
}
开发者ID:megaserg,项目名称:reactchat,代码行数:8,代码来源:handlers.go

示例6: All

func (this *Instance) All(term r.Term, result interface{}) error {
	cursor, err := term.Run(this.session)
	if err != nil {
		return err
	}

	return cursor.All(result)
}
开发者ID:ngthorg,项目名称:grox,代码行数:8,代码来源:rethink.go

示例7: addMessage

func (c *rethinkClient) addMessage(term gorethink.Term, message proto.Message) error {
	data, err := marshaller.MarshalToString(message)
	if err != nil {
		return err
	}
	_, err = term.Insert(gorethink.JSON(data)).RunWrite(c.session)
	return err
}
开发者ID:sr,项目名称:pachyderm,代码行数:8,代码来源:rethink_client.go

示例8: Run

func (d *dbService) Run(t r.Term) (*r.Cursor, error) {
	s, err := d.GetSession()
	if err != nil {
		return nil, err
	}
	defer s.Close()

	return t.Run(s)
}
开发者ID:neutrinoapp,项目名称:neutrino,代码行数:9,代码来源:dbService.go

示例9: ListContains

func ListContains(s *r.Session, t r.Term, name string) (bool, error) {
	rows, err := t.Contains(name).Run(s)
	if err != nil {
		return false, err
	}
	var contains bool
	err = rows.One(&contains)
	if err != nil {
		return false, err
	}

	return contains, nil
}
开发者ID:pombredanne,项目名称:downloaderd-common,代码行数:13,代码来源:dbutils.go

示例10: getMessageByID

func (c *rethinkClient) getMessageByID(term gorethink.Term, id string, message proto.Message) error {
	cursor, err := term.Get(id).ToJSON().Run(c.session)
	if err != nil {
		return err
	}
	data := ""
	if !cursor.Next(&data) {
		return cursor.Err()
	}
	if err := jsonpb.UnmarshalString(data, message); err != nil {
		return err
	}
	return nil
}
开发者ID:sr,项目名称:pachyderm,代码行数:14,代码来源:rethink_client.go

示例11: getMultiRequest

func (s *RequestStore) getMultiRequest(term r.Term, offset uint, count uint) ([]*download.Request, error) {
	var results []*download.Request

	rows, err := term.Slice(offset, (offset + count)).Run(s.Session)
	if err != nil {
		return nil, err
	}

	err = rows.All(&results)
	if err != nil {
		return nil, err
	}

	return results, nil
}
开发者ID:patdowney,项目名称:downloaderd,代码行数:15,代码来源:requeststore.go

示例12: getMultiHook

func (s *HookStore) getMultiHook(term r.Term) ([]*download.Hook, error) {
	var results []*download.Hook

	rows, err := term.Run(s.Session)
	if err != nil {
		return results, err
	}

	err = rows.All(&results)
	if err != nil {
		return nil, err
	}

	return results, nil
}
开发者ID:pombredanne,项目名称:downloaderd-worker,代码行数:15,代码来源:hookstore.go

示例13: getMultiple

func (a *rethinkAPIServer) getMultiple(
	term gorethink.Term,
	messageConstructor func() proto.Message,
	modifiers ...func(gorethink.Term) gorethink.Term,
) ([]interface{}, error) {
	for _, modifier := range modifiers {
		term = modifier(term)
	}
	term = term.Map(func(row gorethink.Term) interface{} {
		return row.ToJSON()
	})
	cursor, err := term.Run(a.session)
	if err != nil {
		return nil, err
	}
	return processMultipleCursor(cursor, messageConstructor)
}
开发者ID:klucar,项目名称:pachyderm,代码行数:17,代码来源:rethink_api_server.go

示例14: getSingleRequest

func (s *RequestStore) getSingleRequest(term r.Term) (*download.Request, error) {
	row, err := term.Run(s.Session)

	if err != nil {
		return nil, err
	}

	if row.IsNil() {
		return nil, nil
	}

	var request download.Request
	err = row.One(&request)
	if err != nil {
		return nil, err
	}
	return &request, nil
}
开发者ID:patdowney,项目名称:downloaderd,代码行数:18,代码来源:requeststore.go

示例15: getSingleDownload

func (s *DownloadStore) getSingleDownload(term r.Term) (*download.Download, error) {
	row, err := term.Run(s.Session)

	if err != nil {
		return nil, err
	}

	if row.IsNil() {
		return nil, nil
	}

	var download download.Download
	err = row.One(&download)
	if err != nil {
		return nil, err
	}
	return &download, nil
}
开发者ID:pombredanne,项目名称:downloaderd-worker,代码行数:18,代码来源:downloadstore.go


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