Module m_edge

Copyright © 2009-2019 Marc Worrell Date: 2009-04-09 Copyright 2009-2019 Marc Worrell Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Behaviours: zotonic_model.

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

Data Types

insert_option()

insert_option() = is_insert_before | no_touch | {seq, integer()} | {creator_id, m_rsc:resource_id()} | {created, calendar:datetime()}

insert_options()

insert_options() = [insert_option()]

Function Index

delete/2Delete an edge by Id.
delete/4Delete an edge by subject, object and predicate id.
delete/5
delete_multiple/4Delete multiple edges between the subject and the object.
duplicate/3Duplicate all edges from one id to another id.
get/2Get the complete edge with the id.
get_edges/2Return the full description of all edges from a subject, grouped by predicate.
get_id/4Get the edge id of a subject/pred/object combination.
get_triple/2Get the edge as a triple {subject_id, predicate, object_id}.
insert/4Insert a new edge.
insert/5
m_get/3Fetch all object/edge ids for a subject/predicate.
merge/3Move all edges from one id to another id, part of m_rsc:merge_delete/3.
object/4Return the Nth object with a certain predicate of a subject.
object_edge_ids/3Return all object ids with the edge id for a predicate/subject_id.
object_edge_props/3Return all object ids with edge properties.
object_predicate_ids/2Return the list of predicate ids in use by edges to objects from the id.
object_predicates/2Return the list of predicates in use by edges to objects from the id.
objects/2Return all object ids of the resource.
objects/3Return all object ids of an id with a certain predicate.
replace/4Replace the objects with the new list.
set_sequence/4Set edges order so that the specified object ids are in given order.
subject/4Return the Nth subject with a certain predicate of an object.
subject_edge_ids/3Return all subject ids with the edge id for a predicate/object_id.
subject_edge_props/3Return all subject ids with the edge properties.
subject_predicate_ids/2Return the list of predicates is use by edges from subjects to the id.
subject_predicates/2Return the list of predicates is use by edges from subjects to the id.
subjects/2Return all subject ids of the resource.
subjects/3Return all subject ids of an object id with a certain predicate.
update_nth/5Update the nth edge of a subject.
update_sequence/4Reorder the edges so that the mentioned ids are in front, in the listed order.
update_sequence_edge_ids/4Update the sequence for the given edge ids.

Function Details

delete/2

delete(Id, Context) -> any()

Delete an edge by Id

delete/4

delete(SubjectId::m_rsc:resource(), Pred::m_rsc:resource(), ObjectId::m_rsc:resource(), Context::z:context()) -> ok | {error, atom()}

Delete an edge by subject, object and predicate id

delete/5

delete(SubjectId::m_rsc:resource(), Pred::m_rsc:resource(), ObjectId::m_rsc:resource(), Options::list(), Context::z:context()) -> ok | {error, atom()}

delete_multiple/4

delete_multiple(SubjectId, Preds, ObjectId, Context) -> any()

Delete multiple edges between the subject and the object

duplicate/3

duplicate(Id::m_rsc:resource(), ToId::m_rsc:resource(), Context::#context{}) -> ok | {error, {atom(), m_rsc:resource_id()}}

Duplicate all edges from one id to another id. Skip all edges that give ACL errors.

get/2

get(Id, Context) -> any()

Get the complete edge with the id

get_edges/2

get_edges(SubjectId, Context) -> any()

Return the full description of all edges from a subject, grouped by predicate

get_id/4

get_id(SubjectId::m_rsc:resource(), PredId::m_rsc:resource(), ObjectId::m_rsc:resource(), Context::#context{}) -> pos_integer() | undefined

Get the edge id of a subject/pred/object combination

get_triple/2

get_triple(Id::pos_integer(), Context::#context{}) -> {m_rsc:resource_id(), atom(), m_rsc:resource_id()}

Get the edge as a triple {subject_id, predicate, object_id}

insert/4

insert(Subject::m_rsc:resource(), Pred::m_rsc:resource(), Object::m_rsc:resource(), Context::z:context()) -> {ok, EdgeId::pos_integer()} | {error, term()}

Insert a new edge

insert/5

insert(SubjectId::m_rsc:resource(), PredId::m_rsc:resource(), ObjectId::m_rsc:resource(), Opts::insert_options(), Context::z:context()) -> {ok, EdgeId::pos_integer()} | {error, term()}

m_get/3

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

Fetch all object/edge ids for a subject/predicate

merge/3

merge(WinnerId, LoserId, Context) -> any()

Move all edges from one id to another id, part of m_rsc:merge_delete/3

object/4

object(Id, Pred, N, Context) -> any()

Return the Nth object with a certain predicate of a subject.

object_edge_ids/3

object_edge_ids(Id, Predicate, Context) -> list()

Return all object ids with the edge id for a predicate/subject_id

object_edge_props/3

object_edge_props(Id::m_rsc:resource_id(), Predicate::binary() | string() | atom() | integer(), Context::z:context()) -> list()

Return all object ids with edge properties

object_predicate_ids/2

object_predicate_ids(Id, Context) -> List

Return the list of predicate ids in use by edges to objects from the id

object_predicates/2

object_predicates(Id, Context) -> List

Return the list of predicates in use by edges to objects from the id

objects/2

objects(Id, Context) -> list()

Return all object ids of the resource

objects/3

objects(SubjectId::m_rsc:resource(), Predicate::m_rsc:resource(), Context::z:context()) -> [m_rsc:resource_id()]

Return all object ids of an id with a certain predicate. The order of the ids is deterministic.

replace/4

replace(SubjectId::m_rsc:resource(), PredId::pos_integer() | atom(), NewObjects::m_rsc:resource(), Context::#context{}) -> ok | {error, atom()}

Replace the objects with the new list

set_sequence/4

set_sequence(Id, Pred::Predicate, ObjectIds, Context) -> ok | {error, Reason}

Set edges order so that the specified object ids are in given order. Any extra edges not specified will be deleted, and any missing edges will be inserted.

subject/4

subject(Id, Pred, N, Context) -> any()

Return the Nth subject with a certain predicate of an object.

subject_edge_ids/3

subject_edge_ids(Id, Predicate, Context) -> list()

Return all subject ids with the edge id for a predicate/object_id

subject_edge_props/3

subject_edge_props(Id::m_rsc:resource_id(), Predicate::binary() | string() | atom() | integer(), Context::z:context()) -> list()

Return all subject ids with the edge properties

subject_predicate_ids/2

subject_predicate_ids(Id, Context) -> List

Return the list of predicates is use by edges from subjects to the id

subject_predicates/2

subject_predicates(Id, Context) -> List

Return the list of predicates is use by edges from subjects to the id

subjects/2

subjects(Id, Context) -> list()

Return all subject ids of the resource

subjects/3

subjects(ObjectId::m_rsc:resource(), Predicate::m_rsc:resource(), Context::z:context()) -> [m_rsc:resource_id()]

Return all subject ids of an object id with a certain predicate. The order of the ids is deterministic.

update_nth/5

update_nth(SubjectId::m_rsc:resource_id(), Predicate::m_rsc:resource(), Nth::m_rsc:resource_id(), ObjectId::integer(), Context::z:context()) -> {ok, pos_integer()} | {error, eacces | enoent}

Update the nth edge of a subject. Set a new object, keep the predicate. If there are not enough edges then an error is returned. The first edge is nr 1.

update_sequence/4

update_sequence(Id, Pred::Predicate, ObjectIds, Context) -> ok | {error, Reason}

Reorder the edges so that the mentioned ids are in front, in the listed order.

update_sequence_edge_ids/4

update_sequence_edge_ids(Id, Pred::Predicate, EdgeIds, Context) -> ok | {error, Reason}

Update the sequence for the given edge ids. Optionally rename the predicate on the edge.


Generated by EDoc