Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

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

Open
GV14982 opened this issue Oct 29, 2020 · 2 comments
Open
Labels
enhancement New feature or request good first issue Good for newcomers low Priority A low priority issue

Comments

@GV14982
Copy link
Owner

GV14982 commented Oct 29, 2020

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 GV14982 added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed low Priority A low priority issue and removed help wanted Extra attention is needed labels Oct 29, 2020
@seanmetzgar
Copy link
Contributor

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.

@GV14982
Copy link
Owner Author

GV14982 commented Nov 6, 2020

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers low Priority A low priority issue
Projects
None yet
Development

No branches or pull requests

2 participants