These are chat archives for frictionlessdata/chat

6th
Jul 2016
Dean Rather
@deanrather
Jul 06 2016 00:05
Does anyone know of an addressing scheme for referring to a particular cell? I guess (in JSONPath) it woud be something like myDatastore[5]['myFieldName']..
Dean Rather
@deanrather
Jul 06 2016 01:02
What do you think?

Table

Name    | Age | Favourite Colour
--------|-----|----------------
Adi     | 10  | Red
Bob     | 20  | Green
Charles | 30  | Blue

Getting in CSV format

GET /datasources/1?format=csv

Name,Age,Favourite Colour
Adi,10,Red
Bob,20,Green
Charles,30,Blue

Getting in JSONAPI format

GET /datasources/1?include=records

{
  data:
  {
    type: datasource,
    id: 1,
    attributes:
    {
      name: My datasource,
      schema:
      {
        fields:
        [
          {name: Name},
          {name: Age},
          {name: Favorite Colour},
        ]
      }
    },
    relationships:
    {
      records:
      {
        data:
        [
          {type: record, id: 1},
          {type: record, id: 2},
          {type: record, id: 3}
        ]
      }
    },
    meta:
    {
      sequence: 1
    },
    links:
    {
      collection: /datasources,
      self: /datasources/1
    }
  },
  included:
  [
    {
      type: record,
      id: 1,
      attributes:
      {
        Name: Adi,
        Age: 10,
        Favorite Colour: Red
      },
      meta:
      {
        sequence: 1
      },
      links:
      {
        collection: /datasources/1,
        self: /datasources/1/records/1
      }
    },
    {
      type: record,
      id: 3,
      attributes:
      {
        Name: Bob,
        Age: 20,
        Favorite Colour: Green
      },
      meta:
      {
        sequence: 2
      },
      links:
      {
        collection: /datasources/1,
        self: /datasources/1/records/2
      }
    },
    {
      type: record,
      id: 3,
      attributes:
      {
        Name: Charles,
        Age: 30,
        Favorite Colour: Blue
      },
      meta:
      {
        sequence: 3
      },
      links:
      {
        collection: /datasources/1,
        self: /datasources/1/records/3
      }
    }
  ]
}

Add new 2nd row:

POST /datasources/1/records
{
  data:
  {
    type: record,
    attributes:
    {
      Name: Annie,
      Age: 15,
      Favorite Colour: Yellow
    },
    meta:
    {
      sequence: 2
    }
  }
}

Modify cell:

PATCH /datasources/1/records/2
{
  data:
  {
    type: record,
    id: 2,
    attributes:
    {
      Age: 21,
    }
  }
}

Add field:

PATCH /datasources/1
{
  data:
  {
    type: datasource,
    id: 1,
    attributes:
    {
      schema:
      {
        fields:
        [
          {name: Name},
          {name: Age},
          {name: Right Handed},
          {name: Favorite Colour},
        ]
      }
  }
}
(I've ommitted quoting strings 'cause I hand-wrote it.. you get the idea)
Rufus Pollock
@rufuspollock
Jul 06 2016 09:18
@deanrather this is great. I'll need to look at your suggest in a bit more detail and in the mean time wanted to flag this original issue thinking about a (read) API for data packages okfn/data.okfn.org-new#6 - this is partially implemented on data.okfn.org/data (BTW that issue was originally frictionlessdata/ideas#19 but it was moved out as it is somewhat specific to building a registry)