Documentation
¶
Index ¶
- Constants
- type DataPage
- type FilterParams
- type PagingParams
- type ProjectionParams
- func NewEmptyProjectionParams() *ProjectionParams
- func NewProjectionParamsFromAnyArray(values *data.AnyValueArray) *ProjectionParams
- func NewProjectionParamsFromStrings(values []string) *ProjectionParams
- func NewProjectionParamsFromValue(value any) *ProjectionParams
- func ParseProjectionParams(values ...string) *ProjectionParams
- func (c *ProjectionParams) Append(elements []string)
- func (c *ProjectionParams) Clear()
- func (c *ProjectionParams) Get(index int) (any, bool)
- func (c *ProjectionParams) IsValidIndex(index int) bool
- func (c *ProjectionParams) Len() int
- func (c *ProjectionParams) Push(value string)
- func (c *ProjectionParams) Put(index int, value string) bool
- func (c *ProjectionParams) Remove(index int)
- func (c *ProjectionParams) String() string
- func (c *ProjectionParams) Value() []string
- type SortField
- type SortParams
- type TokenizedDataPage
- type TokenizedPagingParams
- func NewEmptyTokenizedPagingParams() *TokenizedPagingParams
- func NewTokenizedPagingParams(token string, take int64, total bool) *TokenizedPagingParams
- func NewTokenizedPagingParamsFromMap(value *data.AnyValueMap) *TokenizedPagingParams
- func NewTokenizedPagingParamsFromTuples(tuples ...any) *TokenizedPagingParams
- func NewTokenizedPagingParamsFromValue(value any) *TokenizedPagingParams
Constants ¶
const DefaultSkip int64 = 0
const DefaultTake int64 = 50
const EmptyTokenValue string = ""
const EmptyTotalValue int = -1
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataPage ¶
DataPage is a transfer object that is used to pass results of paginated queries. It contains items of retrieved page and optional total number of items. Most often this object type is used to send responses to paginated queries. Pagination parameters are defined by PagingParams object. The skip parameter in the PagingParams there means how many items to skip. The takes parameter sets number of items to return in the page. And the optional total parameter tells to return total number of items in the query. Remember: not all implementations support the total parameter because its generation may lead to severe performance implications.
see PagingParams Example: page, err := myDataClient.GetDataByFilter( context.Background(), "123", FilterParams.fromTuples("completed": true), NewPagingParams(0, 100, true), ); if err != nil { panic(err) } for item range page.Data { fmt.Println(item); } );
func NewDataPage ¶
NewDataPage creates a new instance of data page and assigns its values.
Parameters: - value data a list of items from the retrieved page. - total int Returns: *DataPage
func NewEmptyDataPage ¶
NewEmptyDataPage creates a new empty instance of data page.
Returns: *DataPage
func (DataPage[T]) MarshalJSON ¶
type FilterParams ¶
type FilterParams struct {
*data.StringValueMap
}
FilterParams is a data transfer object used to pass filter parameters as simple key-value pairs.
see StringValueMap Example: filter := NewFilterParamsFromTuples( "type", "Type1", "from_create_time", time.Now(), "to_create_time", time.Now().Add(10*time.Hour), "completed", true, ) paging = NewPagingParams(0, 100) err, page = myDataClient.getDataByFilter(filter, paging)
func NewEmptyFilterParams ¶
func NewEmptyFilterParams() *FilterParams
NewEmptyFilterParams сreates a new instance.
Returns: *FilterParams
func NewFilterParams ¶
func NewFilterParams(values map[string]string) *FilterParams
NewFilterParams creates a new instance and initialize it with elements from the specified map.
Parameters: - value map[string]string a map to initialize this instance. Returns: *FilterParams
func NewFilterParamsFromString ¶
func NewFilterParamsFromString(line string) *FilterParams
NewFilterParamsFromString parses semicolon-separated key-value pairs and returns them as a FilterParams. see StringValueMap.FromString
Parameters: - line string semicolon-separated key-value list to initialize FilterParams. Returns: *FilterParams
func NewFilterParamsFromTuples ¶
func NewFilterParamsFromTuples(tuples ...any) *FilterParams
NewFilterParamsFromTuples creates a new FilterParams from a list of key-value pairs called tuples.
Parameters: - tuples ...any a list of values where odd elements are keys and the following even elements are values Returns: *FilterParams a newly created FilterParams.
func NewFilterParamsFromValue ¶
func NewFilterParamsFromValue(value any) *FilterParams
NewFilterParamsFromValue converts specified value into FilterParams.
Parameters: - value interface value to be converted Returns: a newly created FilterParams.
type PagingParams ¶
type PagingParams struct { Skip int64 `json:"skip"` Take int64 `json:"take"` Total bool `json:"total"` }
PagingParams is a data transfer object to pass paging parameters for queries.
The page is defined by two parameters: the skip parameter defines number of items to skip. the take parameter sets how many items to return in a page. additionally, the optional total parameter tells to return total number of items in the query. Remember: not all implementations support the total parameter because its generation may lead to severe performance implications. Example: filter := NewFilterParamsFromTuples("type", "Type1"); paging := NewPagingParams(0, 100); err, page = myDataClient.GetDataByFilter(context.Background(), filter, paging);
func NewEmptyPagingParams ¶
func NewEmptyPagingParams() *PagingParams
NewEmptyPagingParams creates a new instance. Returns: *PagingParams
func NewPagingParams ¶
func NewPagingParams(skip, take int64, total bool) *PagingParams
NewPagingParams creates a new instance and sets its values. Parameters:
- skip the number of items to skip.
- take the number of items to return.
- total true to return the total number of items.
Returns: *PagingParams
func NewPagingParamsFromMap ¶
func NewPagingParamsFromMap(value *data.AnyValueMap) *PagingParams
NewPagingParamsFromMap creates a new PagingParams and sets it parameters from the specified map
Parameters: value AnyValueMap or StringValueMap to initialize this PagingParams Returns: *PagingParams a newly created PagingParams.
func NewPagingParamsFromTuples ¶
func NewPagingParamsFromTuples(tuples ...any) *PagingParams
NewPagingParamsFromTuples creates a new PagingParams from a list of key-value pairs called tuples.
Parameters: tuples ...any a list of values where odd elements are keys and the following even elements are values Returns: *PagingParams a newly created PagingParams.
func NewPagingParamsFromValue ¶
func NewPagingParamsFromValue(value any) *PagingParams
NewPagingParamsFromValue converts specified value into PagingParams.
Parameters: value any value to be converted Returns: *PagingParams a newly created PagingParams.
func (*PagingParams) GetSkip ¶
func (c *PagingParams) GetSkip(minSkip int64) int64
GetSkip gets the number of items to skip.
Parameters: minSkip int64 the minimum number of items to skip. Returns: int64 the number of items to skip.
func (*PagingParams) GetTake ¶
func (c *PagingParams) GetTake(maxTake int64) int64
GetTake gets the number of items to return in a page.
Parameters: maxTake int64 the maximum number of items to return. Returns int64 the number of items to return.
type ProjectionParams ¶
type ProjectionParams struct {
// contains filtered or unexported fields
}
ProjectionParams defines projection parameters with list if fields to include into query results. The parameters support two formats: dot format and nested format. The dot format is the standard way to define included fields and subfields using dot object notation: "field1,field2.field21,field2.field22.field221". As alternative the nested format offers a more compact representation: "field1,field2(field21,field22(field221))".
Example: filter := NewFilterParamsFromTuples("type", "Type1"); paging := NewPagingParams(0, 100); projection = NewProjectionParamsFromString("field1,field2(field21,field22)") err, page := myDataClient.GetDataByFilter(context.Background(), filter, paging, projection);
func NewEmptyProjectionParams ¶
func NewEmptyProjectionParams() *ProjectionParams
NewEmptyProjectionParams creates a new instance of the projection parameters and assigns its value.
Returns: *ProjectionParams
func NewProjectionParamsFromAnyArray ¶
func NewProjectionParamsFromAnyArray(values *data.AnyValueArray) *ProjectionParams
NewProjectionParamsFromAnyArray creates a new instance of the projection parameters and assigns its from AnyValueArray values.
Parameters: values *AnyValueArray Returns: *ProjectionParams
func NewProjectionParamsFromStrings ¶
func NewProjectionParamsFromStrings(values []string) *ProjectionParams
NewProjectionParamsFromStrings creates a new instance of the projection parameters and assigns its from string value.
Parameters: values []string Returns: *ProjectionParams
func NewProjectionParamsFromValue ¶
func NewProjectionParamsFromValue(value any) *ProjectionParams
NewProjectionParamsFromValue converts specified value into ProjectionParams.
see AnyValueArray.fromValue Parameters: value any value to be converted Returns: *ProjectionParams a newly created ProjectionParams.
func ParseProjectionParams ¶
func ParseProjectionParams(values ...string) *ProjectionParams
ParseProjectionParams create new ProjectionParams and set values from values
Parameters: values ...string a values to parse Returns: *ProjectionParams
func (*ProjectionParams) Append ¶
func (c *ProjectionParams) Append(elements []string)
Append new elements to an array.
Parameters: value []string
func (*ProjectionParams) Get ¶
func (c *ProjectionParams) Get(index int) (any, bool)
Get value by index Parameters:
- index int an index of element
Return string
func (*ProjectionParams) IsValidIndex ¶
func (c *ProjectionParams) IsValidIndex(index int) bool
IsValidIndex checks that 0 <= index < len.
Parameters: index int an index of the element to get.
Returns: bool
func (*ProjectionParams) Len ¶
func (c *ProjectionParams) Len() int
Len gets or sets the length of the array. This is a number one higher than the highest element defined in an array.
func (*ProjectionParams) Push ¶
func (c *ProjectionParams) Push(value string)
Push new element to an array.
Parameters: value string
func (*ProjectionParams) Put ¶
func (c *ProjectionParams) Put(index int, value string) bool
Put value in index position
Parameters: - index int an index of element - value string value
func (*ProjectionParams) Remove ¶
func (c *ProjectionParams) Remove(index int)
Remove element by index Parameters:
- index int an index of remove element
func (*ProjectionParams) String ¶
func (c *ProjectionParams) String() string
String returns a string representation of an array.
Returns: string
func (*ProjectionParams) Value ¶
func (c *ProjectionParams) Value() []string
Value return raw values []string
type SortField ¶
SortField Defines a field name and order used to sort query results.
see SortParams Example: filter := NewFilterParamsFromTuples("type", "Type1") paging := NewPagingParams(0, 100) sorting := NewSortingParams(NewSortField("create_time", true)) err, page = myDataClient.GetDataByFilter(context.Background(), filter, paging, sorting)
func NewEmptySortField ¶
func NewEmptySortField() SortField
NewEmptySortField creates a new empty instance. Returns SortField
func NewSortField ¶
NewSortField creates a new instance and assigns its values.
Parameters: - name string the name of the field to sort by. - ascending: bool true to sort in ascending order, and false to sort in descending order. Returns: SortField
type SortParams ¶
type SortParams []SortField
SortParams Defines a field name and order used to sort query results.
see SortField Example: filter := NewFilterParamsFromTuples("type", "Type1"); paging := NewPagingParams(0, 100); sorting := NewSortingParams(NewSortField("create_time", true)); myDataClient.getDataByFilter(filter, paging, sorting, (err, page) => {...});
func NewEmptySortParams ¶
func NewEmptySortParams() *SortParams
NewEmptySortParams creates a new instance.
Returns: *SortParams
func NewSortParams ¶
func NewSortParams(fields []SortField) *SortParams
NewSortParams creates a new instance and initializes it with specified sort fields.
Parameters - fields []SortField a list of fields to sort by. Returns: *SortParams
type TokenizedDataPage ¶
TokenizedDataPage is a data transfer object that is used to pass results of paginated queries. It contains items of retrieved page and optional total number of items. Most often this object type is used to send responses to paginated queries. Pagination parameters are defined by TokenizedPagingParams object. The token parameter in the TokenizedPagingParams there determines a starting point for a new search. It is received in the TokenizedDataPage from the previous search. The takes parameter sets number of items to return to the page. And the optional total parameter tells to return total number of items in the query. Remember: not all implementations support the total parameter because its generation may lead to severe performance implications.
see TokenizedPagingParams Example: page, err := myDataClient.GetDataByFilter( context.Background(), "123", NewFilterParamsFromTuples("completed": true), NewTokenizedPagingParams("", 100, true), ); if err != nil { panic(err) } for item range page.Data { fmt.Println(item); }
func NewEmptyTokenizedDataPage ¶
func NewEmptyTokenizedDataPage[T any]() *TokenizedDataPage[T]
NewEmptyTokenizedDataPage creates a new empty instance of data page.
Returns: *TokenizedDataPage[T]
func NewTokenizedDataPage ¶
func NewTokenizedDataPage[T any](token string, data []T) *TokenizedDataPage[T]
NewTokenizedDataPage creates a new instance of data page and assigns its values.
Parameters: - token a token that defines a starting point for next search - data []T a list of items from the retrieved page. Returns: *TokenizedDataPage[T]
func (*TokenizedDataPage[T]) HasData ¶
func (d *TokenizedDataPage[T]) HasData() bool
HasData method check if data exists
func (*TokenizedDataPage[T]) HasToken ¶
func (d *TokenizedDataPage[T]) HasToken() bool
HasToken method check if token exists
type TokenizedPagingParams ¶
type TokenizedPagingParams struct { Token string `json:"token"` Take int64 `json:"take"` Total bool `json:"total"` }
TokenizedPagingParams Data transfer object to pass paging parameters for queries.
The page is defined by two parameters: - the token parameter a starting point for a new page. The token shall be received from previous searches. - the take parameter sets how many items to return in a page.
additionally, the optional total parameter tells to return total number of items in the query. Remember: not all implementations support the total parameter because its generation may lead to severe performance implications.
Example: filter := NewFilterParamsFromTuples("type", "Type1"); paging := NewTokenizedPagingParams("", 100); err, page = myDataClient.GetDataByFilter(context.Background(), filter, paging);
func NewEmptyTokenizedPagingParams ¶
func NewEmptyTokenizedPagingParams() *TokenizedPagingParams
NewEmptyTokenizedPagingParams creates a new instance.
Returns: *TokenizedPagingParams
func NewTokenizedPagingParams ¶
func NewTokenizedPagingParams(token string, take int64, total bool) *TokenizedPagingParams
NewTokenizedPagingParams creates a new instance and sets its values.
Parameters: - token string a token received from previous searches to define a starting point for this search. - take int64 the number of items to return. - total bool true to return the total number of items. Returns: *TokenizedPagingParams
func NewTokenizedPagingParamsFromMap ¶
func NewTokenizedPagingParamsFromMap(value *data.AnyValueMap) *TokenizedPagingParams
NewTokenizedPagingParamsFromMap creates a new TokenizedPagingParams and sets it parameters from the specified map
Parameters: - value AnyValueMap a AnyValueMap or StringValueMap to initialize this TokenizedPagingParams Returns: *TokenizedPagingParams a newly created TokenizedPagingParams.
func NewTokenizedPagingParamsFromTuples ¶
func NewTokenizedPagingParamsFromTuples(tuples ...any) *TokenizedPagingParams
NewTokenizedPagingParamsFromTuples creates a new TokenizedPagingParams from a list of key-value pairs called tuples.
Parameters - tuples ...any a list of values where odd elements are keys and the following even elements are values Returns: *TokenizedPagingParams a newly created TokenizedPagingParams.
func NewTokenizedPagingParamsFromValue ¶
func NewTokenizedPagingParamsFromValue(value any) *TokenizedPagingParams
NewTokenizedPagingParamsFromValue converts specified value into TokenizedPagingParams.
Parameters: - value any value to be converted Returns *TokenizedPagingParams a newly created TokenizedPagingParams.
func (*TokenizedPagingParams) GetTake ¶
func (c *TokenizedPagingParams) GetTake(maxTake int64) int64
GetTake the number of items to return in a page.
Parameters: - maxTake int64 the maximum number of items to return. Returns: int64 the number of items to return.