Relation

AV. Relation

A class that is used to access all of the children of a many-to-many relationship. Each instance of AV.Relation is associated with a particular parent object and key.

Constructor

new Relation(parent, key)

Source:
See:
Creates a new Relation for the given parent object and key. This constructor should rarely be used directly, but rather created by AV.Object#relation.
Parameters:
Name Type Description
parent AV.Object The parent of this relation.
key String The key for this relation on the parent.

Methods

(static) reverseQuery(parentClass, relationKey, child) → {AV.Query}

Source:
Creates a query that can be used to query the parent objects in this relation.
Parameters:
Name Type Description
parentClass String The parent class or name.
relationKey String The relation field key in parent.
child AV.Object The child object.
Returns:
Type
AV.Query

add(objects)

Source:
Adds a AV.Object or an array of AV.Objects to the relation.
Parameters:
Name Type Description
objects AV.Object | Array.<AV.Object> The item or items to add.

query() → {AV.Query}

Source:
Returns a AV.Query that is limited to objects in this relation.
Returns:
Type
AV.Query

remove(objects)

Source:
Removes a AV.Object or an array of AV.Objects from this relation.
Parameters:
Name Type Description
objects AV.Object | Array.<AV.Object> The item or items to remove.

toJSON() → {Object}

Source:
Returns a JSON version of the object suitable for saving to disk.
Returns:
Type
Object