Documentation
¶
Index ¶
- func CompareAny(a, b any) (int, error)
- func ExecAndApply[Row any](ctx context.Context, db *database.DB, executor database.TxOrDB, stmt string, ...) error
- func ForEachRow[Row, Id any](ctx context.Context, db *database.DB, executor database.TxOrDB, ...) error
- func PrefixWithJSONPathRootSelector(path string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareAny ¶ added in v1.0.0
CompareAny compares two values of any type and returns an integer indicating their order (1 if a > b, -1 if a < b, 0 if equal).
func ExecAndApply ¶
func ExecAndApply[Row any]( ctx context.Context, db *database.DB, executor database.TxOrDB, stmt string, args []any, restoreFunc func(*Row), ) error
ExecAndApply applies the provided restoreFunc callback for each successfully retrieved row of the specified type. Returns error on any database failure or fails to acquire the table semaphore.
func ForEachRow ¶
func ForEachRow[Row, Id any]( ctx context.Context, db *database.DB, executor database.TxOrDB, idColumn string, ids []Id, restoreFunc func(*Row), ) error
ForEachRow applies the provided restoreFunc callback for each successfully retrieved row of the specified type. It will bulk SELECT the data from the database scoped to the specified ids and scans into the provided Row type. Returns error on any database failure or fails to acquire the table semaphore.
func PrefixWithJSONPathRootSelector ¶ added in v1.0.0
PrefixWithJSONPathRootSelector ensures that the provided JSONPath expression starts with the root selector ($) and the appropriate separator (dot or bracket).
If the path already starts with a root selector, it is returned unchanged. Otherwise, the function prefixes the path with "$." if it starts with an identifier or "$" if it starts with a bracket.
Types ¶
This section is empty.