m_predicate (zotonic_core v1.0.0-rc.11)

Model for predicates

Link to this section Summary

Functions

Return the list of all predicates
Flush all cached data about predicates.
Return the list of predicates that are valid for the given resource id. Append all predicates that have no restrictions.
Return the definition of the predicate
Lookup the name of a predicate with an id
Insert a new predicate, sets some defaults.
Test if the property is the name of a predicate
Check if a predicate is actually in use for an existing edge.
Fetch the value for the key from a model source
Return the id of the predicate
Return all the valid categories for objects. Return the empty list when there is no constraint. Note that the resulting array is a bit strangely formatted [{id}, {id2}, ...], this is compatible with the category name lookup and prevents mixups with strings (lists of integers).
Return the category ids that are valid as objects
Return all the valid categories for subjects. Return the empty list when there is no constraint. Note that the resulting array is a bit strangely formatted [{id}, {id2}, ...], this is compatible with the category name lookup and prevents mixups with strings (lists of integers).
Return the category ids that are valid as subjects
Reset the list of valid subjects and objects.

Link to this section Functions

Return the list of all predicates
Flush all cached data about predicates.
Link to this function

for_subject(Id, Context)

Return the list of predicates that are valid for the given resource id. Append all predicates that have no restrictions.
Link to this function

get(PredId, Context)

-spec get(atom() | m_rsc:resource_id() | string() | binary(), z:context()) -> list() | undefined.
Return the definition of the predicate
Link to this function

id_to_name(Id, Context)

-spec id_to_name(m_rsc:resource_id(), z:context()) ->
              {ok, atom()} | {error, {unknown_predicate, term()}}.
Lookup the name of a predicate with an id
Link to this function

insert(Title, Context)

-spec insert(binary() | list(), z:context()) -> {ok, integer()} | {error, any()}.
Insert a new predicate, sets some defaults.
Link to this function

is_predicate(Id, Context)

Test if the property is the name of a predicate
Link to this function

is_used(Predicate, Context)

Check if a predicate is actually in use for an existing edge.
Link to this function

m_get(Rest, Msg, Context)

-spec m_get(list(), zotonic_model:opt_msg(), z:context()) -> zotonic_model:return().
Fetch the value for the key from a model source
Link to this function

name_to_id(Name, Context)

-spec name_to_id(m_rsc:resource_name(), z:context()) ->
              {ok, m_rsc:resource_id()} | {error, {unknown_predicate, term()}}.
Return the id of the predicate
Link to this function

object_category(Id, Context)

Return all the valid categories for objects. Return the empty list when there is no constraint. Note that the resulting array is a bit strangely formatted [{id}, {id2}, ...], this is compatible with the category name lookup and prevents mixups with strings (lists of integers).
Link to this function

objects(Id, Context)

Return the category ids that are valid as objects
Link to this function

subject_category(Id, Context)

Return all the valid categories for subjects. Return the empty list when there is no constraint. Note that the resulting array is a bit strangely formatted [{id}, {id2}, ...], this is compatible with the category name lookup and prevents mixups with strings (lists of integers).
Link to this function

subjects(Id, Context)

Return the category ids that are valid as subjects
Link to this function

update_noflush(Id, Subjects, Objects, Context)

-spec update_noflush(integer(), list(), list(), z:context()) -> ok.
Reset the list of valid subjects and objects.