View Source Arke.Core.Query (Arke v1.1.33)
Struct which defines a Query
Link to this section Summary
Functions
Add a filter to a query
Add a filter to a query
Add a filter to a query
Add a new link filter
Get the query result ordered by specific criteria
Create a new Query
Create a new base filter
Create a new filter
Create a new filter
Define the limit of the query
Define the offset of the query
Link to this section Types
Link to this section Functions
Add a filter to a query
parameters
Parameters
- query => refer to
new/1
- filter => refer to
Arke.Core.Query.BaseFilter
example
Example
iex> person = Arke.Core.Arke.new(id: :person, label: "Person")
...> query = Arke.Core.Query.new(person, :arke_system)
...> parameter = Arke.Boundary.ParameterManager.get(:id,:arke_system)
...> filter = Arke.Core.Query.new_filter(parameter,:eq, "name", false)
...> Arke.Core.Query.add_filter(query, filter)
return
Return
%Arke.Core.Query{... filters: [ %Arke.Core.Query.Filter{} ] ... }
Add a filter to a query
parameters
Parameters
- query => refer to
new/1
logic => :and | :or => the logic of the filter
- negate => boolean => used to figure out whether the condition is to be denied
- base_filters
example
Example
iex> person = Arke.new(id: :person, label: "Person")
...> query = Arke.Core.Query.new(person, :arke_system)
...> parameter = Arke.Core.ParameterManager.get(:id,:arke_system)
...> Arke.Core.Query.add_filter(query, parameter, :eq, "name", false)
return
Return
%Arke.Core.Query{... filters: [ %Arke.Core.Query.Filter{} ] ... }
Add a filter to a query
parameters
Parameters
- query => refer to
new/1
- parameter
- operator
- value
- negate
example
Example
iex> person = Arke.Core.Arke.new(id: :person, label: "Person")
...> query = Arke.Core.Query.new(person, :arke_system)
...> parameter = Arke.Boundary.ParameterManager.get(:id,:arke_system)
...> base_filter = Arke.Core.Query.new_base_filter(parameter, :eq, "name", false)
...> Arke.Core.Query.add_filter(query, :and, false, base_filter)
return
Return
%Arke.Core.Query{... filters: [ %Arke.Core.Query.Filter{} ] ... }
@spec add_link_filter( query :: t(), unit :: Arke.Core.Unit.t(), depth :: integer(), direction :: atom(), connection_type :: String.t() ) :: t()
Add a new link filter
parameters
Parameters
- query => refer to
new/1
- unit => %Arke.Core.
{arke_struct}
{} => thearke_struct
of the unit which we want to filter on. SeeArke.Struct
- depth => integer => how many results we want to have at max
direction => "child" | "parent" => the direction the query will use to search
- type => the name of the link we want to look at
example
Example
iex> person = Arke.Core.Arke.new(id: :person, label: "Person")
...> query = Arke.Core.Query.new(person, :arke_system)
...> Arke.Core.Query.add_link_filter(query, person, 0, "child", "link")
return
Return
%Arke.Core.Query{... link: %Arke.Core.Query.LinkFilter{} ... }
Get the query result ordered by specific criteria
parameters
Parameters
- query => refer to refer to
new/1
- parameter => %Arke.Core.Parameter.
ParameterType
=> refer toArke.Core.Parameter
direction => "child" | "parent" => the direction the query will use to search
example
Example
iex> person = Arke.Core.Arke.new(id: "person", label: "Person")
...> query = Arke.Core.Query.new(person, :arke_system)
...> parameter = Arke.Boundary.ParameterManager.get(:id,:arke_system)
...> Arke.Core.Query.add_order(query, parameter, :asc)
return
Return
%Arke.Core.Query{ ... orders: [ %Arke.Core.Query.Order{} ] ... }
@spec new( arke :: %Arke.Core.Arke{ active: term(), id: term(), label: term(), parameters: term(), type: term() }, project :: atom() ) :: t()
Create a new Query
parameters
Parameters
- arke => %Arke.Core.
{arke_struct}
{} => thearke_struct
of the unit which we want to filter on. SeeArke.Struct
- project => :atom => identify the
Arke.Core.Project
example
Example
iex> person = Arke.Core.Arke.new(id: "person", label: "Person")
...> Arke.Core.Query.new(person, :default)
return
Return
%Arke.Core.Query{}
Create a new base filter
parameters
Parameters
- parameter => %Arke.Core.Parameter.
ParameterType
=> refer toArke.Core.Parameter
- operator => refer to operators
- value => any => the value that the query will search for
- negate => boolean => used to figure out whether the condition is to be denied
example
Example
iex> parameter = Arke.Boundary.ParameterManager.get(:id,:arke_system)
...> Arke.Core.Query.new_base_filter(parameter, :eq, "name", false)
return
Return
%Arke.Core.Query.BaseFilter{}
Create a new filter
parameters
Parameters
logic => :and | :or => the logic of the filter
- negate => boolean => used to figure out whether the condition is to be denied
- base_filters => refer to
Arke.Core.Query.BaseFilter
example
Example
iex> base_filter = Arke.Core.Query.new_base_filter(parameter, :eq, "name", false)
...> Arke.Core.Query.new_filter(:and, false, base_filter)
return
Return
%Arke.Core.Query.Filter{base_filters: [ %Arke.Core.Query.BaseFilter{} ]}
Create a new filter
parameters
Parameters
- parameter => %Arke.Core.Parameter.
ParameterType
=> refer toArke.Core.Parameter
- operator => refer to operators
- value => any => the value that the query will search for
- negate => boolean => used to figure out whether the condition is to be denied
example
Example
iex> parameter = Arke.Boundary.ParameterManager.get(:id,:arke_system)
...> Arke.Core.Query.new_filter(parameter,:eq, "name", false)
return
Return
%Arke.Core.Query.Filter{base_filters: [ %Arke.Core.Query.BaseFilter{} ]}
Define the limit of the query
parameters
Parameters
- query => refer to
new/1
- limit => integer => set the results limit of the query
example
Example
iex> person = Arke.Core.Arke.new(id: :person, label: "Person")
...> query = Arke.Core.Query.new(person, :arke_system)
...> Arke.Core.Query.set_limit(query, 100)
return
Return
%Arke.Core.Query{... limit: value ...}
Define the offset of the query
parameters
Parameters
- query => refer to
new/1
- offset => integer => define the offset of the query
example
Example
iex> person = Arke.Core.Arke.new(id: :person, label: "Person")
...> query = Arke.Core.Query.new(person, :arke_system)
...> Arke.Core.Query.set_offset(query, 5)
return
Return
%Arke.Core.Query{... offset: value ...}