View Source ExTeal.Api.ManyToMany (ExTeal v0.28.1)

API Responder that manages the many to many relationships via:

  • GET attachable - Querying the potentially related
  • POST attach - Adding a related resource
  • DELETE detach - Removing a related resource
  • GET creation-pivot-fields - Fetch the pivot fields associated with a relationship

Summary

Functions

Given a request of POST /api/posts/1/attach/tags that contains a set of params like

Given a request of GET /api/resource_uri/resource_id/attachable/field_name This function returns a response that contains the attachable schemas associated with the many to many relationship at field_name

Returns a list of fields associated with the pivot table of a many to many relationship. Fields are only for attaching to a many to many

Given a request of DELETE /api/posts/1/attach/tags/2 that contains a set of params like

Batch Updates a pivot schema's fields for reordering a relationship

Returns a list of fields associated with the pivot table of a many to many relationship for an existing relationship.

Returns a list of fields associated with the pivot table of a many to many relationship for an existing relationship.

Functions

Link to this function

attach(conn, resource_uri, resource_id, field_name)

View Source

Given a request of POST /api/posts/1/attach/tags that contains a set of params like:

%{
  "viaRelationship" => "tags",
  "tags" => "2"
}

This function attaches the tag with id 2 to the posts tags relationship.

Link to this function

attachable(conn, resource_uri, resource_id, field_name)

View Source

Given a request of GET /api/resource_uri/resource_id/attachable/field_name This function returns a response that contains the attachable schemas associated with the many to many relationship at field_name

Link to this function

creation_pivot_fields(conn, resource_uri, field_name)

View Source

Returns a list of fields associated with the pivot table of a many to many relationship. Fields are only for attaching to a many to many

Link to this function

detach(conn, resource_uri, resource_id, field_name)

View Source

Given a request of DELETE /api/posts/1/attach/tags/2 that contains a set of params like:

This function detaches the tag with id 2 from the posts tags relationship.

Link to this function

reorder(conn, resource_uri, resource_id, field_name)

View Source

Batch Updates a pivot schema's fields for reordering a relationship

Link to this function

update_pivot(conn, resource_uri, resource_id, field_name, related_id)

View Source

Returns a list of fields associated with the pivot table of a many to many relationship for an existing relationship.

Link to this function

update_pivot_fields(conn, resource_uri, resource_id, field_name, related_id)

View Source

Returns a list of fields associated with the pivot table of a many to many relationship for an existing relationship.