Product Help

Util Package Methods and Functions

ParseTime

func ParseTime(raw interface{}) (time.Time, error)

ParseTime parses time from an interface{} value.

Parameters:

  • raw: Time to parse.

Returns:

  • time.Time: The parsed Time.

  • error: Any errors from the function.

PrepareQuery

func PrepareQuery(namedQuery string, params map[string]interface{}) (string, []interface{}, error)

PrepareQuery converts named parameters in the query to positional placeholders and returns the transformed query along with an args slice.

Parameters:

  • namedQuery: Query to prepare.

  • params: Parameters that will be inserted into the namedQuery.

Returns:

  • string: Transformed query.

  • []interface{}: Arguments slice.

  • error: Any errors from the function.

FormatQueryWithBindings

func FormatQueryWithBindings(query string, bindings map[string]interface{}) string

FormatQueryWithBindings converts bindings into a query.

Parameters:

  • query: The query to be formated.

  • bindings: A map of bindings to insert into the query.

Returns:

  • string: The formatted query.

GenerateConstraintCommand

func GenerateConstraintCommand(constraintName, label, property, constraintType string) command.CypherCommand

GenerateConstraintCommand generates a constraint based on the parameters passed in.

Parameters:

  • Get inserted in CREATE CONSTRAINT %s IF NOT EXISTS FOR (n:%s) REQUIRE n.%s IS %s;"

Returns:

  • command.CypherCommand: A new CypherCommand.

SerializeIfNeeded

func SerializeIfNeeded(v interface{}) (interface{}, error)

SerializeIfNeeded serializes certain structures to JSON strings if needed.

DeserializeIfNeeded

func DeserializeIfNeeded(v interface{}) (interface{}, error)

DeserializeIfNeeded attempts to deserialize a JSON string into a map or slice if it can.

AssertStringSlice

func AssertStringSlice(v interface{}) ([]string, error)

AssertStringSlice ensures an interface{} is a []string.

ConvertInterfaceSliceToStringSlice

func ConvertInterfaceSliceToStringSlice(input []interface{}) ([]string, error)

ConvertInterfaceSliceToStringSlice converts []interface{} to []string.

Last modified: 28 January 2025