View Source ExTypesense.Parser (ExTypesense v0.2.2)

Module for converting structs to raw json body or map.

Link to this section Summary

Functions

Gets ecto schema fields and turns it into a list of maps as field entries.

Converts an ecto schema module (e.g. Posts) to a map.

Link to this section Types

@type collection() :: %{
  name: String.t(),
  fields: [map()],
  default_sorting_field: String.t()
}

Link to this section Functions

Link to this function

get_fields(module_name)

View Source (since 0.1.0)
@spec get_fields(module()) :: [map()]

Gets ecto schema fields and turns it into a list of maps as field entries.

Link to this function

struct_to_map(module_name, default_sorting_field \\ "")

View Source (since 0.1.0)
@spec struct_to_map(module(), String.t()) :: collection()

Converts an ecto schema module (e.g. Posts) to a map.

examples

Examples

default_sorting_field = "title"
iex> ExTypesense.Parser.struct_to_map(AppModule, default_sorting_field)
%{
  default_sorting_field: "title",
  fields: [...],
  name: "companies"
}
Link to this function

struct_to_raw_body(module_name, default_sorting_field \\ "")

View Source (since 0.1.0)
@spec struct_to_raw_body(module(), String.t()) :: String.t()