async-airtable icon indicating copy to clipboard operation
async-airtable copied to clipboard

✨ Add support for a filter formula or query on the update methods.

Open GV14982 opened this issue 5 years ago • 2 comments

We should add support for a filter formula string or query on the update methods, so it doesn't have to be done by ID.

Something like:

asyncAirtable.update('table', {
  where: "{name} = 'Graham'" // This is just a standard filter formula string, and will need to be updated when we build the query builder too, so we don't have a fragmented user experience
  fields: {
    hungry: false
  }
}); 

Then be sure to update all tests and documentation.

GV14982 avatar Oct 29 '20 01:10 GV14982

Hey @GV14982, I'll hop on this today (11/6/2020). I'll also address a little Issue I discovered while researching it. (re: the following quote from the Airtable API)

"Your request body should include an array of up to 10 record objects."

I may add a new method for this, as to not break the syntax for users using .updateRecord or .bulkUpdate. Perhaps something like .filteredUpdate? Let me know what you think.

seanmetzgar avatar Nov 06 '20 06:11 seanmetzgar

I may add a new method for this, as to not break the syntax for users using .updateRecord or .bulkUpdate. Perhaps something like .filteredUpdate? Let me know what you think.

I mean that's perfectly fine. The other option is to provide either an ID or a filterString in the top level, then the fields object, something like:

{
  id?: string
  filterString?: string
  fields: {
    ...fields
  }
}

But then in the method you check if there is an ID, and if not, you check if there is a filterString. If there is a filterString, you do a select with it, then grab the ID from the first result and use that for the update.

You'll have to adjust the interface for the updateRecord, and probably extend from a base one with one that requires the id and the other that requires the filterString.

Let me know if that makes sense or if you have any questions.

GV14982 avatar Nov 06 '20 13:11 GV14982