本文整理汇总了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)
}
示例2: Exec
func (this *Instance) Exec(term r.Term) error {
session, err := this.connect()
if err != nil {
return err
}
return term.Exec(session)
}
示例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)
}
示例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)
}
示例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()}
}
}()
}
示例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)
}
示例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
}
示例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)
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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)
}
示例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
}
示例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
}