Documentation
¶
Index ¶
- func ArrayAgg(exp builder.Exp) builder.AggExpBuilder
- func Avg(exp builder.Exp) builder.AggExpBuilder
- func BitAnd(exp builder.Exp) builder.AggExpBuilder
- func BitOr(exp builder.Exp) builder.AggExpBuilder
- func BitXor(exp builder.Exp) builder.AggExpBuilder
- func BoolAnd(exp builder.Exp) builder.AggExpBuilder
- func BoolOr(exp builder.Exp) builder.AggExpBuilder
- func Count(exp builder.Exp) builder.AggExpBuilder
- func CumeDist(args ...builder.Exp) builder.AggExpBuilder
- func DenseRank(args ...builder.Exp) builder.AggExpBuilder
- func Extract(field string, from builder.Exp) builder.ExpBase
- func Grouping(exps ...builder.Exp) builder.AggExpBuilder
- func Initcap(identer builder.Exp) builder.ExpBase
- func JsonAgg(exp builder.Exp) builder.AggExpBuilder
- func JsonArrayElements(exp builder.Exp) builder.ExpBase
- func JsonArrayElementsText(exp builder.Exp) builder.ExpBase
- func JsonArrayLength(exp builder.Exp) builder.ExpBase
- func JsonBuildObject() builder.JsonBuildObjectBuilder
- func JsonEach(exp builder.Exp) builder.ExpBase
- func JsonEachText(exp builder.Exp) builder.ExpBase
- func JsonExtractPath(fromJson builder.Exp, pathElems ...builder.Exp) builder.ExpBase
- func JsonExtractPathText(fromJson builder.Exp, pathElems ...builder.Exp) builder.ExpBase
- func JsonObjectAgg(key, value builder.Exp) builder.AggExpBuilder
- func JsonObjectKeys(exp builder.Exp) builder.ExpBase
- func JsonPopulateRecord(base builder.Exp, fromJson builder.Exp) builder.ExpBase
- func JsonPopulateRecordset(base builder.Exp, fromJson builder.Exp) builder.ExpBase
- func JsonStripNulls(exp builder.Exp) builder.ExpBase
- func JsonToRecord(exp builder.Exp) builder.FuncBuilder
- func JsonToRecordset(exp builder.Exp) builder.FuncBuilder
- func JsonTypeof(exp builder.Exp) builder.ExpBase
- func JsonbAgg(exp builder.Exp) builder.AggExpBuilder
- func JsonbArrayElements(exp builder.Exp) builder.ExpBase
- func JsonbArrayElementsText(exp builder.Exp) builder.ExpBase
- func JsonbArrayLength(exp builder.Exp) builder.ExpBase
- func JsonbBuildObject() builder.JsonBuildObjectBuilder
- func JsonbEach(exp builder.Exp) builder.ExpBase
- func JsonbEachText(exp builder.Exp) builder.ExpBase
- func JsonbExtractPath(fromJson builder.Exp, pathElems ...builder.Exp) builder.ExpBase
- func JsonbExtractPathText(fromJson builder.Exp, pathElems ...builder.Exp) builder.ExpBase
- func JsonbInsert(target builder.Exp, path builder.Exp, newValue builder.Exp, ...) builder.ExpBase
- func JsonbObjectAgg(key, value builder.Exp) builder.AggExpBuilder
- func JsonbObjectKeys(exp builder.Exp) builder.ExpBase
- func JsonbPathExists(target builder.Exp, path builder.Exp, options ...builder.Exp) builder.ExpBase
- func JsonbPathExistsTZ(target builder.Exp, path builder.Exp, options ...builder.Exp) builder.ExpBase
- func JsonbPathMatch(target builder.Exp, path builder.Exp, options ...builder.Exp) builder.ExpBase
- func JsonbPathMatchTZ(target builder.Exp, path builder.Exp, options ...builder.Exp) builder.ExpBase
- func JsonbPathQuery(target builder.Exp, path builder.Exp, options ...builder.Exp) builder.ExpBase
- func JsonbPathQueryArray(target builder.Exp, path builder.Exp, options ...builder.Exp) builder.ExpBase
- func JsonbPathQueryArrayTZ(target builder.Exp, path builder.Exp, options ...builder.Exp) builder.ExpBase
- func JsonbPathQueryFirst(target builder.Exp, path builder.Exp, options ...builder.Exp) builder.ExpBase
- func JsonbPathQueryFirstTZ(target builder.Exp, path builder.Exp, options ...builder.Exp) builder.ExpBase
- func JsonbPathQueryTZ(target builder.Exp, path builder.Exp, options ...builder.Exp) builder.ExpBase
- func JsonbPopulateRecord(base builder.Exp, fromJson builder.Exp) builder.ExpBase
- func JsonbPopulateRecordset(base builder.Exp, fromJson builder.Exp) builder.ExpBase
- func JsonbPretty(exp builder.Exp) builder.ExpBase
- func JsonbSet(target builder.Exp, path builder.Exp, newValue builder.Exp, ...) builder.ExpBase
- func JsonbSetLax(target builder.Exp, path builder.Exp, newValue builder.Exp, ...) builder.ExpBase
- func JsonbStripNulls(exp builder.Exp) builder.ExpBase
- func JsonbToRecord(exp builder.Exp) builder.FuncBuilder
- func JsonbToRecordset(exp builder.Exp) builder.FuncBuilder
- func JsonbTypeof(exp builder.Exp) builder.ExpBase
- func Lower(identer builder.Exp) builder.ExpBase
- func Max(exp builder.Exp) builder.AggExpBuilder
- func Min(exp builder.Exp) builder.AggExpBuilder
- func Mode() builder.AggExpBuilder
- func PercentRank(args ...builder.Exp) builder.AggExpBuilder
- func PercentileCont(fraction builder.Exp) builder.AggExpBuilder
- func PercentileDisc(fraction builder.Exp) builder.AggExpBuilder
- func RangeAgg(value builder.Exp) builder.AggExpBuilder
- func RangeIntersectAgg(value builder.Exp) builder.AggExpBuilder
- func Rank(args ...builder.Exp) builder.AggExpBuilder
- func StringAgg(value, delimiter builder.Exp) builder.AggExpBuilder
- func Sum(exp builder.Exp) builder.AggExpBuilder
- func Upper(identer builder.Exp) builder.ExpBase
- func Xmlagg(exp builder.Exp) builder.AggExpBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArrayAgg ¶
func ArrayAgg(exp builder.Exp) builder.AggExpBuilder
ArrayAgg builds the array_agg aggregate function.
array_agg ( anynonarray ) → anyarray
Collects all the input values, including nulls, into an array.
array_agg ( anyarray ) → anyarray
Concatenates all the input arrays into an array of one higher dimension.
func Avg ¶
func Avg(exp builder.Exp) builder.AggExpBuilder
Avg builds the avg aggregate function.
avg ( T ) → T
Computes the average (arithmetic mean) of all the non-null input values.
func BitAnd ¶
func BitAnd(exp builder.Exp) builder.AggExpBuilder
BitAnd builds the bit_and aggregate function.
bit_and ( T ) → T
Computes the bitwise AND of all non-null input values.
func BitOr ¶
func BitOr(exp builder.Exp) builder.AggExpBuilder
BitOr builds the bit_or aggregate function.
bit_or ( T ) → T
Computes the bitwise OR of all non-null input values.
func BitXor ¶
func BitXor(exp builder.Exp) builder.AggExpBuilder
BitXor builds the bit_xor aggregate function.
bit_xor ( T ) → T
Computes the bitwise exclusive OR of all non-null input values. Can be useful as a checksum for an unordered set of values.
func BoolAnd ¶
func BoolAnd(exp builder.Exp) builder.AggExpBuilder
BoolAnd builds the bool_and aggregate function.
bool_and ( boolean ) → boolean
Returns true if all non-null input values are true, otherwise false.
func BoolOr ¶
func BoolOr(exp builder.Exp) builder.AggExpBuilder
BoolOr builds the bool_or aggregate function.
bool_or ( boolean ) → boolean
Returns true if any non-null input value is true, otherwise false.
func Count ¶
func Count(exp builder.Exp) builder.AggExpBuilder
Count builds the count aggregate function.
count ( * ) → bigint
Computes the number of input rows.
count ( expression ) → bigint
Computes the number of input rows in which the input value is not null.
Example:
builder.Select(fn.Count(builder.N("*"))).From("table")
func CumeDist ¶
func CumeDist(args ...builder.Exp) builder.AggExpBuilder
CumeDist builds the cume_dist aggregate function.
cume_dist ( args ) WITHIN GROUP ( ORDER BY sorted_args ) → double precision
Computes the cumulative distribution, that is (number of rows preceding or peers with hypothetical row) / (total rows). The value thus ranges from 1/N to 1.
func DenseRank ¶
func DenseRank(args ...builder.Exp) builder.AggExpBuilder
DenseRank builds the dense_rank aggregate function.
dense_rank ( args ) WITHIN GROUP ( ORDER BY sorted_args ) → bigint
Computes the rank of the hypothetical row, without gaps; this function effectively counts peer groups.
func Grouping ¶
func Grouping(exps ...builder.Exp) builder.AggExpBuilder
Grouping builds the grouping operation.
GROUPING ( group_by_expression(s) ) → integer
Returns a bit mask indicating which GROUP BY expressions are not included in the current grouping set. Bits are assigned with the rightmost argument corresponding to the least-significant bit; each bit is 0 if the corresponding expression is included in the grouping criteria of the grouping set generating the current result row, and 1 if it is not included.
func JsonAgg ¶
func JsonAgg(exp builder.Exp) builder.AggExpBuilder
JsonAgg builds the json_agg aggregate function.
json_agg ( anyelement ) → json
Collects all the input values, including nulls, into a JSON array. Values are converted to JSON as per to_json.
func JsonArrayElements ¶ added in v0.8.0
JsonArrayElements builds the json_array_elements function.
( json ) → setof json
Expands the top-level JSON array into a set of JSON values.
func JsonArrayElementsText ¶ added in v0.8.0
JsonArrayElementsText builds the json_array_elements_text function.
( json ) → setof text
Expands the top-level JSON array into a set of text values.
func JsonArrayLength ¶ added in v0.8.0
JsonArrayLength builds the json_array_length function.
( json ) → integer
Returns the number of elements in the top-level JSON array.
func JsonBuildObject ¶
func JsonBuildObject() builder.JsonBuildObjectBuilder
JsonBuildObject builds the json_build_object function. It is based on a builder pattern to specify properties (see builder.JsonBuildObjectBuilder).
( VARIADIC "any" ) → json
Builds a JSON object out of a variadic argument list. By convention, the argument list consists of alternating keys and values. Key arguments are coerced to text; value arguments are converted as per to_json.
func JsonEach ¶ added in v0.8.0
JsonEach builds the json_each function.
( json ) → setof record ( key text, value json )
Expands the top-level JSON object into a set of key/value pairs.
func JsonEachText ¶ added in v0.8.0
JsonEachText builds the json_each_text function.
( json ) → setof record ( key text, value text )
Expands the top-level JSON object into a set of key/value pairs. The returned values will be of type text.
func JsonExtractPath ¶ added in v0.8.0
JsonExtractPath builds the json_extract_path function.
( from_json json, VARIADIC path_elems text[] ) → json
Extracts JSON sub-object at the specified path. (This is functionally equivalent to the #> operator, but writing the path out as a variadic list can be more convenient in some cases.)
func JsonExtractPathText ¶ added in v0.8.0
JsonExtractPathText builds the json_extract_path_text function.
( from_json json, VARIADIC path_elems text[] ) → text
Extracts JSON sub-object at the specified path as text. (This is functionally equivalent to the #>> operator.)
func JsonObjectAgg ¶
func JsonObjectAgg(key, value builder.Exp) builder.AggExpBuilder
JsonObjectAgg builds the json_object_agg aggregate function.
json_object_agg ( key "any", value "any" ) → json
Collects all the key/value pairs into a JSON object. Key arguments are coerced to text; value arguments are converted as per to_json. Values can be null, but not keys.
func JsonObjectKeys ¶ added in v0.8.0
JsonObjectKeys builds the json_object_keys function.
( json ) → setof text
Returns the set of keys in the top-level JSON object.
func JsonPopulateRecord ¶ added in v0.8.0
JsonPopulateRecord builds the json_populate_record function.
( base anyelement, from_json json ) → anyelement
Expands the top-level JSON object to a row having the composite type of the base argument. The JSON object is scanned for fields whose names match column names of the output row type, and their values are inserted into those columns of the output. (Fields that do not correspond to any output column name are ignored.) In typical use, the value of base is just NULL, which means that any output columns that do not match any object field will be filled with nulls. However, if base isn't NULL then the values it contains will be used for unmatched columns.
func JsonPopulateRecordset ¶ added in v0.8.0
JsonPopulateRecordset builds the json_populate_recordset function.
( base anyelement, from_json json ) → setof anyelement
Expands the top-level JSON array of objects to a set of rows having the composite type of the base argument. Each element of the JSON array is processed as described above for json[b]_populate_record.
func JsonStripNulls ¶ added in v0.8.0
JsonStripNulls builds the json_strip_nulls function.
( json ) → json
Deletes all object fields that have null values from the given JSON value, recursively. Null values that are not object fields are untouched.
func JsonToRecord ¶ added in v0.8.0
func JsonToRecord(exp builder.Exp) builder.FuncBuilder
JsonToRecord builds the json_to_record function.
( json ) → record
Expands the top-level JSON object to a row having the composite type defined by an AS clause. (As with all functions returning record, the calling query must explicitly define the structure of the record with an AS clause.) The output record is filled from fields of the JSON object, in the same way as described above for json[b]_populate_record. Since there is no input record value, unmatched columns are always filled with nulls.
func JsonToRecordset ¶ added in v0.8.0
func JsonToRecordset(exp builder.Exp) builder.FuncBuilder
JsonToRecordset builds the json_to_recordset function.
( json ) → setof record
Expands the top-level JSON array of objects to a set of rows having the composite type defined by an AS clause. (As with all functions returning record, the calling query must explicitly define the structure of the record with an AS clause.) Each element of the JSON array is processed as described above for json[b]_populate_record.
func JsonTypeof ¶ added in v0.8.0
JsonTypeof builds the json_typeof function.
( json ) → text
Returns the type of the top-level JSON value as a text string. Possible types are object, array, string, number, boolean, and null. (The null result should not be confused with an SQL NULL; see the examples.)
func JsonbAgg ¶
func JsonbAgg(exp builder.Exp) builder.AggExpBuilder
JsonbAgg builds the json_agg aggregate function.
jsonb_agg ( anyelement ) → jsonb
Collects all the input values, including nulls, into a JSON array. Values are converted to JSON as per to_jsonb.
func JsonbArrayElements ¶ added in v0.8.0
JsonbArrayElements builds the jsonb_array_elements function.
( jsonb ) → setof jsonb
Expands the top-level JSON array into a set of JSON values.
func JsonbArrayElementsText ¶ added in v0.8.0
JsonbArrayElementsText builds the jsonb_array_elements_text function.
( jsonb ) → setof text
Expands the top-level JSON array into a set of text values.
func JsonbArrayLength ¶ added in v0.8.0
JsonbArrayLength builds the jsonb_array_length function.
( jsonb ) → integer
Returns the number of elements in the top-level JSON array.
func JsonbBuildObject ¶ added in v0.5.0
func JsonbBuildObject() builder.JsonBuildObjectBuilder
JsonbBuildObject builds the json_build_object function. It is based on a builder pattern to specify properties (see builder.JsonBuildObjectBuilder).
( VARIADIC "any" ) → jsonb
Builds a JSON object out of a variadic argument list. By convention, the argument list consists of alternating keys and values. Key arguments are coerced to text; value arguments are converted as per to_jsonb.
func JsonbEach ¶ added in v0.8.0
JsonbEach builds the jsonb_each function.
( jsonb ) → setof record ( key text, value jsonb )
Expands the top-level JSON object into a set of key/value pairs.
func JsonbEachText ¶ added in v0.8.0
JsonbEachText builds the jsonb_each_text function.
( jsonb ) → setof record ( key text, value text )
Expands the top-level JSON object into a set of key/value pairs. The returned values will be of type text.
func JsonbExtractPath ¶ added in v0.8.0
JsonbExtractPath builds the json_extract_path function.
( from_json jsonb, VARIADIC path_elems text[] ) → jsonb
Extracts JSON sub-object at the specified path. (This is functionally equivalent to the #> operator, but writing the path out as a variadic list can be more convenient in some cases.)
func JsonbExtractPathText ¶ added in v0.8.0
JsonbExtractPathText builds the jsonb_extract_path_text function.
( from_json jsonb, VARIADIC path_elems text[] ) → text
Extracts JSON sub-object at the specified path as text. (This is functionally equivalent to the #>> operator.)
func JsonbInsert ¶ added in v0.8.0
func JsonbInsert(target builder.Exp, path builder.Exp, newValue builder.Exp, insertAfter ...builder.Exp) builder.ExpBase
JsonbInsert builds the jsonb_insert function.
( target jsonb, path text[], new_value jsonb [, insert_after boolean ] ) → jsonb
Returns target with new_value inserted. If the item designated by the path is an array element, new_value will be inserted before that item if insert_after is false (which is the default), or after it if insert_after is true. If the item designated by the path is an object field, new_value will be inserted only if the object does not already contain that key. All earlier steps in the path must exist, or the target is returned unchanged. As with the path oriented operators, negative integers that appear in the path count from the end of JSON arrays. If the last path step is an array index that is out of range, the new value is added at the beginning of the array if the index is negative, or at the end of the array if it is positive.
func JsonbObjectAgg ¶
func JsonbObjectAgg(key, value builder.Exp) builder.AggExpBuilder
JsonbObjectAgg builds the jsonb_object_agg aggregate function.
jsonb_object_agg ( key "any", value "any" ) → jsonb
Collects all the key/value pairs into a JSON object. Key arguments are coerced to text; value arguments are converted as per to_jsonb. Values can be null, but not keys.
func JsonbObjectKeys ¶ added in v0.8.0
JsonbObjectKeys builds the jsonb_object_keys function.
( jsonb ) → setof text
Returns the set of keys in the top-level JSON object.
func JsonbPathExists ¶ added in v0.8.0
JsonbPathExists builds the jsonb_path_exists function.
( target jsonb, path jsonpath [, vars jsonb [, silent boolean ]] ) → boolean
Checks whether the JSON path returns any item for the specified JSON value. If the vars argument is specified, it must be a JSON object, and its fields provide named values to be substituted into the jsonpath expression. If the silent argument is specified and is true, the function suppresses the same errors as the @? and @@ operators do.
func JsonbPathExistsTZ ¶ added in v0.8.0
func JsonbPathExistsTZ(target builder.Exp, path builder.Exp, options ...builder.Exp) builder.ExpBase
JsonbPathExistsTZ builds the jsonb_path_exists function.
( target jsonb, path jsonpath [, vars jsonb [, silent boolean ]] ) → boolean
Checks whether the JSON path returns any item for the specified JSON value. If the vars argument is specified, it must be a JSON object, and its fields provide named values to be substituted into the jsonpath expression. If the silent argument is specified and is true, the function suppresses the same errors as the @? and @@ operators do. This function acts like its counterpart without the _tz suffix, except that this functions supports comparisons of date/time values that require timezone-aware conversions. Due to this dependency, this function is marked as stable, which means this function cannot be used in indexes. The counterpart is immutable, and so can be used in indexes; but it will throw errors if asked to make such comparisons.
func JsonbPathMatch ¶ added in v0.8.0
JsonbPathMatch builds the jsonb_path_match function.
( target jsonb, path jsonpath [, vars jsonb [, silent boolean ]] ) → boolean
Returns the result of a JSON path predicate check for the specified JSON value. Only the first item of the result is taken into account. If the result is not Boolean, then NULL is returned. The optional vars and silent arguments act the same as for jsonb_path_exists.
func JsonbPathMatchTZ ¶ added in v0.8.0
JsonbPathMatchTZ builds the jsonb_path_match function.
( target jsonb, path jsonpath [, vars jsonb [, silent boolean ]] ) → boolean
Returns the result of a JSON path predicate check for the specified JSON value. Only the first item of the result is taken into account. If the result is not Boolean, then NULL is returned. The optional vars and silent arguments act the same as for jsonb_path_exists. This function acts like its counterpart without the _tz suffix, except that this functions supports comparisons of date/time values that require timezone-aware conversions. Due to this dependency, this function is marked as stable, which means this function cannot be used in indexes. The counterpart is immutable, and so can be used in indexes; but it will throw errors if asked to make such comparisons.
func JsonbPathQuery ¶ added in v0.8.0
JsonbPathQuery builds the jsonb_path_query function.
( target jsonb, path jsonpath [, vars jsonb [, silent boolean ]] ) → setof jsonb
Returns all JSON items returned by the JSON path for the specified JSON value. The optional vars and silent arguments act the same as for jsonb_path_exists.
func JsonbPathQueryArray ¶ added in v0.8.0
func JsonbPathQueryArray(target builder.Exp, path builder.Exp, options ...builder.Exp) builder.ExpBase
JsonbPathQueryArray builds the jsonb_path_query_array function.
( target jsonb, path jsonpath [, vars jsonb [, silent boolean ]] ) → jsonb
Returns all JSON items returned by the JSON path for the specified JSON value, as a JSON array. The optional vars and silent arguments act the same as for jsonb_path_exists.
func JsonbPathQueryArrayTZ ¶ added in v0.8.0
func JsonbPathQueryArrayTZ(target builder.Exp, path builder.Exp, options ...builder.Exp) builder.ExpBase
JsonbPathQueryArrayTZ builds the jsonb_path_query_array function.
( target jsonb, path jsonpath [, vars jsonb [, silent boolean ]] ) → jsonb
Returns all JSON items returned by the JSON path for the specified JSON value, as a JSON array. The optional vars and silent arguments act the same as for jsonb_path_exists. This function acts like its counterpart without the _tz suffix, except that this functions supports comparisons of date/time values that require timezone-aware conversions. Due to this dependency, this function is marked as stable, which means this function cannot be used in indexes. The counterpart is immutable, and so can be used in indexes; but it will throw errors if asked to make such comparisons.
func JsonbPathQueryFirst ¶ added in v0.8.0
func JsonbPathQueryFirst(target builder.Exp, path builder.Exp, options ...builder.Exp) builder.ExpBase
JsonbPathQueryFirst builds the jsonb_path_query_first function.
( target jsonb, path jsonpath [, vars jsonb [, silent boolean ]] ) → jsonb
Returns the first JSON item returned by the JSON path for the specified JSON value. Returns NULL if there are no results. The optional vars and silent arguments act the same as for jsonb_path_exists.
func JsonbPathQueryFirstTZ ¶ added in v0.8.0
func JsonbPathQueryFirstTZ(target builder.Exp, path builder.Exp, options ...builder.Exp) builder.ExpBase
JsonbPathQueryFirstTZ builds the jsonb_path_query_first function.
( target jsonb, path jsonpath [, vars jsonb [, silent boolean ]] ) → jsonb
Returns the first JSON item returned by the JSON path for the specified JSON value. Returns NULL if there are no results. The optional vars and silent arguments act the same as for jsonb_path_exists. This function acts like its counterpart without the _tz suffix, except that this functions supports comparisons of date/time values that require timezone-aware conversions. Due to this dependency, this function is marked as stable, which means this function cannot be used in indexes. The counterpart is immutable, and so can be used in indexes; but it will throw errors if asked to make such comparisons.
func JsonbPathQueryTZ ¶ added in v0.8.0
JsonbPathQueryTZ builds the jsonb_path_query function.
( target jsonb, path jsonpath [, vars jsonb [, silent boolean ]] ) → setof jsonb
Returns all JSON items returned by the JSON path for the specified JSON value. The optional vars and silent arguments act the same as for jsonb_path_exists. This function acts like its counterpart without the _tz suffix, except that this functions supports comparisons of date/time values that require timezone-aware conversions. Due to this dependency, this function is marked as stable, which means this function cannot be used in indexes. The counterpart is immutable, and so can be used in indexes; but it will throw errors if asked to make such comparisons.
func JsonbPopulateRecord ¶ added in v0.8.0
JsonbPopulateRecord builds the jsonb_populate_record function.
( base anyelement, from_json jsonb ) → anyelement
Expands the top-level JSON object to a row having the composite type of the base argument. The JSON object is scanned for fields whose names match column names of the output row type, and their values are inserted into those columns of the output. (Fields that do not correspond to any output column name are ignored.) In typical use, the value of base is just NULL, which means that any output columns that do not match any object field will be filled with nulls. However, if base isn't NULL then the values it contains will be used for unmatched columns.
func JsonbPopulateRecordset ¶ added in v0.8.0
JsonbPopulateRecordset builds the jsonb_populate_recordset function.
( base anyelement, from_json jsonb ) → setof anyelement
Expands the top-level JSON array of objects to a set of rows having the composite type of the base argument. Each element of the JSON array is processed as described above for json[b]_populate_record.
func JsonbPretty ¶ added in v0.8.0
JsonbPretty builds the jsonb_pretty function.
( jsonb ) → text
Converts the given JSON value to pretty-printed, indented text.
func JsonbSet ¶ added in v0.8.0
func JsonbSet(target builder.Exp, path builder.Exp, newValue builder.Exp, createIfMissing ...builder.Exp) builder.ExpBase
JsonbSet builds the jsonb_set function.
( target jsonb, path text[], new_value jsonb [, create_if_missing boolean ] ) → jsonb
Returns target with the item designated by path replaced by new_value, or with new_value added if create_if_missing is true (which is the default) and the item designated by path does not exist. All earlier steps in the path must exist, or the target is returned unchanged. As with the path oriented operators, negative integers that appear in the path count from the end of JSON arrays. If the last path step is an array index that is out of range, and create_if_missing is true, the new value is added at the beginning of the array if the index is negative, or at the end of the array if it is positive.
func JsonbSetLax ¶ added in v0.8.0
func JsonbSetLax(target builder.Exp, path builder.Exp, newValue builder.Exp, options ...builder.Exp) builder.ExpBase
JsonbSetLax builds the jsonb_set_lax function.
( target jsonb, path text[], new_value jsonb [, create_if_missing boolean [, null_value_treatment text ]] ) → jsonb
If new_value is not NULL, behaves identically to jsonb_set. Otherwise behaves according to the value of null_value_treatment which must be one of 'raise_exception', 'use_json_null', 'delete_key', or 'return_target'. The default is 'use_json_null'.
func JsonbStripNulls ¶ added in v0.8.0
JsonbStripNulls builds the jsonb_strip_nulls function.
( jsonb ) → jsonb
Deletes all object fields that have null values from the given JSON value, recursively. Null values that are not object fields are untouched.
func JsonbToRecord ¶ added in v0.8.0
func JsonbToRecord(exp builder.Exp) builder.FuncBuilder
JsonbToRecord builds the jsonb_to_record function.
( jsonb ) → record
Expands the top-level JSON object to a row having the composite type defined by an AS clause. (As with all functions returning record, the calling query must explicitly define the structure of the record with an AS clause.) The output record is filled from fields of the JSON object, in the same way as described above for json[b]_populate_record. Since there is no input record value, unmatched columns are always filled with nulls.
func JsonbToRecordset ¶ added in v0.8.0
func JsonbToRecordset(exp builder.Exp) builder.FuncBuilder
JsonbToRecordset builds the jsonb_to_recordset function.
( jsonb ) → setof record
Expands the top-level JSON array of objects to a set of rows having the composite type defined by an AS clause. (As with all functions returning record, the calling query must explicitly define the structure of the record with an AS clause.) Each element of the JSON array is processed as described above for json[b]_populate_record.
func JsonbTypeof ¶ added in v0.8.0
JsonbTypeof builds the jsonb_typeof function.
( jsonb ) → text
Returns the type of the top-level JSON value as a text string. Possible types are object, array, string, number, boolean, and null. (The null result should not be confused with an SQL NULL; see the examples.)
func Max ¶
func Max(exp builder.Exp) builder.AggExpBuilder
Max builds the max aggregate function.
max ( see text ) → same as input type
Computes the maximum of the non-null input values. Available for any numeric, string, date/time, or enum type, as well as inet, interval, money, oid, pg_lsn, tid, xid8, and arrays of any of these types.
func Min ¶
func Min(exp builder.Exp) builder.AggExpBuilder
Min builds the min aggregate function.
min ( see text ) → same as input type
Computes the minimum of the non-null input values. Available for any numeric, string, date/time, or enum type, as well as inet, interval, money, oid, pg_lsn, tid, xid8, and arrays of any of these types.
func Mode ¶
func Mode() builder.AggExpBuilder
Mode builds the mode aggregate function.
mode () WITHIN GROUP ( ORDER BY anyelement ) → anyelement
Computes the mode, the most frequent value of the aggregated argument (arbitrarily choosing the first one if there are multiple equally-frequent values). The aggregated argument must be of a sortable type.
func PercentRank ¶
func PercentRank(args ...builder.Exp) builder.AggExpBuilder
PercentRank builds the percent_rank aggregate function.
percent_rank ( args ) WITHIN GROUP ( ORDER BY sorted_args ) → double precision
Computes the relative rank of the hypothetical row, that is (rank - 1) / (total rows - 1). The value thus ranges from 0 to 1 inclusive.
func PercentileCont ¶
func PercentileCont(fraction builder.Exp) builder.AggExpBuilder
PercentileCont builds the percentile_cont aggregate function.
percentile_cont ( fraction double precision ) WITHIN GROUP ( ORDER BY double precision ) → double precision percentile_cont ( fraction double precision ) WITHIN GROUP ( ORDER BY interval ) → interval percentile_cont ( fractions double precision[] ) WITHIN GROUP ( ORDER BY double precision ) → double precision[] percentile_cont ( fractions double precision[] ) WITHIN GROUP ( ORDER BY interval ) → interval[]
Computes the continuous percentile, a value corresponding to the specified fraction within the ordered set of aggregated argument values. This will interpolate between adjacent input items if needed.
func PercentileDisc ¶
func PercentileDisc(fraction builder.Exp) builder.AggExpBuilder
PercentileDisc builds the percentile_disc aggregate function.
percentile_disc ( fraction double precision ) WITHIN GROUP ( ORDER BY anyelement ) → anyelement
Computes the discrete percentile, the first value within the ordered set of aggregated argument values whose position in the ordering equals or exceeds the specified fraction. The aggregated argument must be of a sortable type.
percentile_disc ( fractions double precision[] ) WITHIN GROUP ( ORDER BY anyelement ) → anyarray
Computes multiple discrete percentiles. The result is an array of the same dimensions as the fractions parameter, with each non-null element replaced by the input value corresponding to that percentile. The aggregated argument must be of a sortable type.
func RangeAgg ¶
func RangeAgg(value builder.Exp) builder.AggExpBuilder
RangeAgg builds the range_agg aggregate function.
range_agg ( value anyrange ) → anymultirange range_agg ( value anymultirange ) → anymultirange
Computes the union of the non-null input values.
func RangeIntersectAgg ¶
func RangeIntersectAgg(value builder.Exp) builder.AggExpBuilder
RangeIntersectAgg builds the range_intersect_agg aggregate function.
range_intersect_agg ( value anyrange ) → anyrange range_intersect_agg ( value anymultirange ) → anymultirange
Computes the intersection of the non-null input values.
func Rank ¶
func Rank(args ...builder.Exp) builder.AggExpBuilder
Rank builds the rank aggregate function.
rank ( args ) WITHIN GROUP ( ORDER BY sorted_args ) → bigint
Computes the rank of the hypothetical row, with gaps; that is, the row number of the first row in its peer group.
func StringAgg ¶
func StringAgg(value, delimiter builder.Exp) builder.AggExpBuilder
StringAgg builds the string_agg aggregate function.
string_agg ( value text, delimiter text ) → text string_agg ( value bytea, delimiter bytea ) → bytea
Concatenates the non-null input values into a string. Each value after the first is preceded by the corresponding delimiter (if it's not null).
Types ¶
This section is empty.