Module m_predicate

Model for predicates.

Copyright © 2009 Marc Worrell Date: 2009-04-09

Behaviours: zotonic_model.

Authors: Marc Worrell (marc@worrell.nl).

Description

Model for predicates

Function Index

all/1Return the list of all predicates.
flush/1Flush all cached data about predicates.
for_subject/2Return the list of predicates that are valid for the given resource id.
get/2Return the definition of the predicate.
id_to_name/2Lookup the name of a predicate with an id.
insert/2Insert a new predicate, sets some defaults.
is_predicate/2Test if the property is the name of a predicate.
is_used/2Check if a predicate is actually in use for an existing edge.
m_get/3Fetch the value for the key from a model source.
name_to_id/2Return the id of the predicate.
object_category/2Return all the valid categories for objects.
objects/2Return the category ids that are valid as objects.
subject_category/2Return all the valid categories for subjects.
subjects/2Return the category ids that are valid as subjects.
update_noflush/4Reset the list of valid subjects and objects.

Function Details

all/1

all(Context) -> PropList

Return the list of all predicates

flush/1

flush(Context) -> any()

Flush all cached data about predicates.

for_subject/2

for_subject(Id, Context) -> any()

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

get/2

get(PredId::atom() | m_rsc:resource_id() | string() | binary(), Context::z:context()) -> list() | undefined

Return the definition of the predicate

id_to_name/2

id_to_name(Id::m_rsc:resource_id(), Context::z:context()) -> {ok, atom()} | {error, {unknown_predicate, term()}}

Lookup the name of a predicate with an id

insert/2

insert(Title::binary() | list(), Context::z:context()) -> {ok, integer()} | {error, any()}

Insert a new predicate, sets some defaults.

is_predicate/2

is_predicate(Id::Pred, Context) -> bool()

Test if the property is the name of a predicate

is_used/2

is_used(Predicate, Context) -> any()

Check if a predicate is actually in use for an existing edge.

m_get/3

m_get(Rest::list(), Msg::zotonic_model:opt_msg(), Context::z:context()) -> zotonic_model:return()

Fetch the value for the key from a model source

name_to_id/2

name_to_id(Name::m_rsc:resource_name(), Context::z:context()) -> {ok, m_rsc:resource_id()} | {error, {unknown_predicate, term()}}

Return the id of the predicate

object_category/2

object_category(Id, Context) -> List

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).

objects/2

objects(Id, Context) -> any()

Return the category ids that are valid as objects

subject_category/2

subject_category(Id, Context) -> List

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).

subjects/2

subjects(Id, Context) -> any()

Return the category ids that are valid as subjects

update_noflush/4

update_noflush(Id::integer(), Subjects::list(), Objects::list(), Context::z:context()) -> ok

Reset the list of valid subjects and objects.


Generated by EDoc