Adding existing resources to collections

Story

As an application user I want to be able to add people to the list of event attendees So I know who attended the event

As an application user I want to be able to add event to the list of events I attended So I can keep track on events I attended

As an API consumer I want to be able to add existing resources to collections So I can create various meaningful associations

TODO

  • define operation for adding existing resources to a collection Issue#134

Details

Each event can reference a collection which acts as list of the attendees

GET /api/events/1
HTTP 200 OK
{
    "@context": "/api/context.jsonld",
    "@id": "/api/events/1",
    "@type": "schema:Event",
    "eventName": "Event 1",
    "collection": {
      "@id": "/api/events/1/attendees",
      "title": "List of attendees",
      "@type": "Collection",
      "manages": [
        {
          "property": "rdf:type",
          "object": "schema:Person"
        },
        {
          "subject": "/api/events/1",
          "property": "schema:attendee"
        }
      ],
      "operation": {
        "@type": ["Operation", "schema:AddAction"],
        "title": "Add event attendee",
        "method": "LINK",
        "expects": "schema:Person"
      }

    }
}

Similarly, each person can reference a collection which lists the events this person attended:

GET /api/people/1
HTTP 200 OK
{
    "@context": "/api/context.jsonld",
    "@id": "/api/people/1",
    "@type": "schema:Person",
    "schema:name": "Alice Foobarion",
    "collection": {
      "@id": "/api/people/1/attended",
      "title": "List of attended events",
      "@type": "Collection",
      "manages": [
        {
          "property": "rdf:type",
          "object": "schema:Event"
        },
        {
          "property": "schema:attendee",
          "object": "/api/person/1",
        }
      ],
      "operation": {
        "@type": ["Operation", "schema:AddAction"],
        "title": "Add attended event",
        "method": "LINK",
        "expects": "schema:Event"
      }

    }
}

In both cases the schema:AddAction operation expects an existing resource (with an @id) and just adds it to collection's member array. Unlike schema:CreateAction explained in Creating a new event document.

results matching ""

    No results matching ""