rethink.go
func (s RethinkStore) FilterGet(filter map[string]interface{}, store string, dst interface{}, opts ObjectStoreOptions) error {

	// var rootTerm = s.getRootTerm(store, filter, opts)
	var rootTerm = r.DB(s.Database).Table(store)
	if opts != nil {
		indexes := opts.GetIndexes()
		for k := range indexes {
			if val, ok := filter[k].(string); ok {
				rootTerm = rootTerm.GetAllByIndex(k, val)
				break
			}
		}
	}
	rootTerm = rootTerm.Filter(s.transformFilter(nil, filter))
	result, err := rootTerm.Limit(1).Run(s.Session)
	logger.Debug("FilterGet::done", "store", store, "query", rootTerm.String())
	if err != nil {
		logger.Error("failed to get", "err", err.Error())
		return err
	}
	defer result.Close()
	if result.Err() != nil {
		return result.Err()
	}
	if result.IsNil() == true {
		return ErrNotFound
	}
	if err := result.One(dst); err != nil {
		println(err.Error())
		if err == r.ErrEmptyResult {
			return ErrNotFound
		} else {
			return err
		}

	}
	return nil
}
func (s RethinkStore) FilterGet(filter map[string]interface{}, store string, dst interface{}, opts ObjectStoreOptions) error {

	// var rootTerm = s.getRootTerm(store, filter, opts)
	var rootTerm = r.DB(s.Database).Table(store)
	if opts != nil {
		indexes := opts.GetIndexes()
		for k := range indexes {
			if val, ok := filter[k].(string); ok {
				rootTerm = rootTerm.GetAllByIndex(k, val)
				break
			}
		}
	}
	rootTerm = rootTerm.Filter(s.transformFilter(nil, filter))
	result, err := rootTerm.Limit(1).Run(s.Session)
	logger.Debug("FilterGet::done", "store", store, "query", rootTerm.String())
	if err != nil {
		logger.Error("failed to get", "err", err.Error())
		return err
	}
	defer result.Close()
	if result.Err() != nil {
		return result.Err()
	}
	if result.IsNil() == true {
		return ErrNotFound
	}
	if err := result.One(dst); err != nil {
		println(err.Error())
		if err == r.ErrEmptyResult {
			return ErrNotFound
		} else {
			return err
		}

	}
	return nil
}
func ( s RethinkStore ) FilterGet ( filter map [ string ] interface { } , store string , dst interface { } , opts ObjectStoreOptions ) error { // var rootTerm = s.getRootTerm(store, filter, opts) var rootTerm = r . DB ( s . Database ) . Table ( store ) if opts != nil { indexes := opts . GetIndexes ( ) for k := range indexes { if val , ok := filter [ k ] . ( string ) ; ok { rootTerm = rootTerm . GetAllByIndex ( k , val ) break } } } rootTerm = rootTerm . Filter ( s . transformFilter ( nil , filter ) ) result , err := rootTerm . Limit ( 1 ) . Run ( s . Session ) logger . Debug ( " " , " " , store , " " , rootTerm . String ( ) ) if err != nil { logger . Error ( " " , " " , err . Error ( ) ) return err } defer result . Close ( ) if result . Err ( ) != nil { return result . Err ( ) } if result . IsNil ( ) == true { return ErrNotFound } if err := result . One ( dst ) ; err != nil { println ( err . Error ( ) ) if err == r . ErrEmptyResult { return ErrNotFound } else { return err } } return nil }
/*
FilterGet retrieves only one item based on a filter
It is used as a shortcut to FilterGetAll with size == 1
*/
/ * FilterGet retrieves only one item based on a filter It is used as a shortcut to FilterGetAll with size == 1