I’m building a private Pack that pulls information from an API into a Coda table. Most of the information that the API returns is a string or a number, but there’s one field that’s an array. For example:
{ "items": [
{
"stringProperty": "String",
"numberProperty": 2,
"arrayProperty": ["cat", "dog", "fish", "bird"],
}
}
Where the arrayProperty
could contain any number of values.
I think I’ve got my schema set up to handle the array (or at least the Pack isn’t returning an error — hat tip to Pack formula resultType of object with property type of StringArray? for that one). The schema looks like this:
const mySchema = coda.makeObjectSchema({
properties: {
stringProperty: { type: coda.ValueType.String },
numberProperty: {
type: coda.ValueType.Number,
fromKey: "id",
},
arrayProperty: {
type: coda.ValueType.Array,
items: { type: coda.ValueType.String }
},
}
On the resulting table when I install the Pack, the arrayProperty column’s type is Text.
What I’d now like to do is create a related table that shows all the arrayProperty
items individually, and be able to create another column in the related table that counts the unique uses of each item (how many times “cat” appears overall, how many times “dog” appears, etc.).
I have tried changing the arrayProperty
column to column type “Relation” and “Create a new table,” which does seem to make a table of the individual array items; however, when I create a number column with a formula (First Table.filter(arrayProperty = thisrow.arrayProperty).Count()
), I only get results for rows with cat
or dog
in them individually (so, given cat
and cat, dog
, the formula column returns just 1 for cat
and 0 for dog
, not 2 and 1 respectively).
I figure this is just a matter of my configuring something wrong. Can anyone point me in the right direction? Thanks!