async-airtable
async-airtable copied to clipboard
✨ Add support for a filter formula or query on the update methods.
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.
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.
I may add a new method for this, as to not break the syntax for users using
.updateRecordor.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.