mirror of
https://github.com/FlipsideCrypto/flip-rpc-client-go.git
synced 2026-02-06 10:56:45 +00:00
Add fields to query api.
This commit is contained in:
parent
b7e5d49a42
commit
c40d001588
@ -95,6 +95,23 @@ func makeWindowingQuery() dynamicquery.Query {
|
||||
return query
|
||||
}
|
||||
|
||||
func makeFieldsQuery() dynamicquery.Query {
|
||||
|
||||
fields := make([]dynamicquery.Field, 0)
|
||||
fields = append(fields, dynamicquery.Field{
|
||||
Label: "tx_id",
|
||||
Field: "tx_id",
|
||||
})
|
||||
|
||||
query := dynamicquery.Query{
|
||||
Table: "udm_events_aion",
|
||||
Schema: "source",
|
||||
Fields: &fields,
|
||||
Limit: 5,
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
func TestClient_GetSegmentMembers(t *testing.T) {
|
||||
client := getClient(t)
|
||||
|
||||
@ -166,6 +183,26 @@ func TestClient_ExecuteDynamicQueryWithWindowing(t *testing.T) {
|
||||
fmt.Println("")
|
||||
}
|
||||
|
||||
func TestClient_ExecuteDynamicQueryWithFields(t *testing.T) {
|
||||
client := getClient(t)
|
||||
|
||||
resp, err := client.ExecuteDynamicQuery(makeFieldsQuery(), false, 10)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
if resp == nil {
|
||||
t.Fatal("resp is nil")
|
||||
}
|
||||
|
||||
if resp.Error != "" {
|
||||
t.Fatalf("error is not empty %s", resp.Error)
|
||||
}
|
||||
|
||||
fmt.Fprintln(os.Stdout, "TestClient_ExecuteDynamicQueryWithFields")
|
||||
fmt.Fprintln(os.Stdout, *resp)
|
||||
fmt.Println("")
|
||||
}
|
||||
|
||||
func TestClient_ExecuteDynamicQueryWithError(t *testing.T) {
|
||||
client := getClient(t)
|
||||
query := makeQuery(makeCondition())
|
||||
|
||||
9
dynamicquery/field.go
Normal file
9
dynamicquery/field.go
Normal file
@ -0,0 +1,9 @@
|
||||
package dynamicquery
|
||||
|
||||
// Field selects a field to return
|
||||
type Field struct {
|
||||
Field string `json:"field"`
|
||||
Label string `json:"label"`
|
||||
DecimalAdjustment int `json:"decimal_adjustment"`
|
||||
ToNegative bool `json:"to_negative"`
|
||||
}
|
||||
@ -11,6 +11,7 @@ type Query struct {
|
||||
Filter *Filter `json:"filter,omitempty"`
|
||||
OrderBy []OrderBy `json:"order_by"`
|
||||
Limit int `json:"limit"`
|
||||
Fields *[]Field `json:"fields,omitempty"`
|
||||
Latest *Latest `json:"latest,omitempty"`
|
||||
Earliest *Earliest `json:"earliest,omitempty"`
|
||||
Segments map[string]segment.Condition `json:"segments"`
|
||||
|
||||
Loading…
Reference in New Issue
Block a user