dlex v0.5.1 Dlex.Node
Simple high level API for accessing graphs
Usage
defmodule Shared do
use Dlex.Node
shared do
field :id, :string, index: ["term"]
field :name, :string, index: ["term"]
endend
defmodule User do
use Dlex.Node, depends_on: Shared
schema "user" do
field :id, :auto
field :name, :auto
endend
defmodule User do
use Dlex.Node
schema "user" do
field :id, :auto, depends_on: Shared
field :name, :string, index: ["term"]
field :age, :integer
field :cache, :any, virtual: true
field :owns, :uid
endend
Dgraph types:
* `:integer`
* `:float`
* `:string`
* `:geo`
* `:datetime`
* `:uid`
* `:auto` - special type, which can be used for `depends_on`Reflection
Any schema module will generate the __schema__ function that can be
used for runtime introspection of the schema:
__schema__(:source)- Returns the source as given toschema/2;__schema__(:fields)- Returns a list of all non-virtual field names;__schema__(:alter)- Returns a generated alter schema__schema__(:field, field)- Returns the name of field in database for field in a struct and vice versa;__schema__(:type, field)- Returns the type of the given non-virtual field;
Additionally it generates Ecto compatible __changeset__ for using with Ecto.Changeset.