AshNeo4j Util
Summary
Functions
Validates that an atom is a valid Neo4j edge label (i.e. contains only uppercase letters and underscores)
Validates that an atom is a valid Neo4j node label (i.e. starts with an uppercase letter and contains only letters and numbers)
Validates that an atom is a valid Neo4j property name (i.e. does not start with a number and does not contain spaces or special characters)
Encodes json, converting structs and maps to ordered objects sorted by key, even when in lists/nested Deliberately does not call Jason.Encoder on structs, since Protocol may not be implemented for persistence/at all
Returns the reverse direction
Returns the short name for an Elixir Module
Converts an Elixir snake_case atom to Neo4j camelCase atom, used for node properties
Converts an Elixir snake_case atom to Neo4j MACRO_CASE atom, used for edge labels
Converts an Elixir snake_case atom to Neo4j PascalCase atom, used for node labels
Whether the given module uses Ash.TypedStruct
Functions
Validates that an atom is a valid Neo4j edge label (i.e. contains only uppercase letters and underscores)
Examples
iex> AshNeo4j.Util.is_valid_edge_label?(:VALID_LABEL)
true
iex> AshNeo4j.Util.is_valid_edge_label?(:invalid_label)
false
Validates that an atom is a valid Neo4j node label (i.e. starts with an uppercase letter and contains only letters and numbers)
Examples
iex> AshNeo4j.Util.is_valid_node_label?(:ValidLabel)
true
iex> AshNeo4j.Util.is_valid_node_label?(:invalid_label)
false
Validates that an atom is a valid Neo4j property name (i.e. does not start with a number and does not contain spaces or special characters)
Examples
iex> AshNeo4j.Util.is_valid_property_name?(:validName)
true
iex> AshNeo4j.Util.is_valid_property_name?(:invalid_name)
false
Encodes json, converting structs and maps to ordered objects sorted by key, even when in lists/nested Deliberately does not call Jason.Encoder on structs, since Protocol may not be implemented for persistence/at all
Examples
iex> AshNeo4j.Util.json_encode(%{name: "Henry", age: 8, breed: :groodle})
{:ok, ~s({"age":8,"breed":"groodle","name":"Henry"})}
iex> AshNeo4j.Util.json_encode([%{currency: :aud, amount: 100}, %{currency: :sek, amount: 650}])
{:ok, ~s([{"amount":100,"currency":"aud"},{"amount":650,"currency":"sek"}])}
iex> AshNeo4j.Util.json_encode(%Ash.Union{type: :typed_struct, value: %AshNeo4j.Test.Type.DogTypedStruct{name: "Henry", age: 8, breed: "groodle"}})
{:ok, ~s({"type":"typed_struct","value":{"age":8,"breed":"groodle","name":"Henry"}})}
Returns the reverse direction
Returns the short name for an Elixir Module
Examples
iex> AshNeo4j.Util.short_name(MyApp.Domain.User)
:User
Converts an Elixir snake_case atom to Neo4j camelCase atom, used for node properties
Examples
iex> AshNeo4j.Util.to_camel_case(:snake_case)
:snakeCase
iex> AshNeo4j.Util.to_camel_case(:UUID)
:uuid
Converts an Elixir snake_case atom to Neo4j MACRO_CASE atom, used for edge labels
Examples
iex> AshNeo4j.Util.to_macro_case(:snake_case)
:SNAKE_CASE
iex> AshNeo4j.Util.to_macro_case(:belongs_to)
:BELONGS_TO
Converts an Elixir snake_case atom to Neo4j PascalCase atom, used for node labels
Examples
iex> AshNeo4j.Util.to_pascal_case(:snake_case)
:SnakeCase
iex> AshNeo4j.Util.to_pascal_case(:domain)
:Domain
Whether the given module uses Ash.TypedStruct
Examples
iex> AshNeo4j.Util.typed_struct?(AshNeo4j.Test.Type.DogTypedStruct)
true
iex> AshNeo4j.Util.typed_struct?(List)
false