Multi-record list

This commit is contained in:
Ian Gulliver
2024-06-22 15:33:14 -07:00
parent 8ea1e9731b
commit ea516a559f
4 changed files with 42 additions and 31 deletions

View File

@@ -38,23 +38,17 @@ func (c *Client) GetTable(dbName, tableName string) *Table {
}
}
// GetRecordsWithParams get records with url values params
// https://airtable.com/{yourDatabaseID}/api/docs#curl/table:{yourTableName}:list
func (t *Table) GetRecordsWithParams(params url.Values) (*Records, error) {
func (t *Table) GetRecordsWithParams(params url.Values) ([]*Record, error) {
return t.GetRecordsWithParamsContext(context.Background(), params)
}
// GetRecordsWithParamsContext get records with url values params
// with custom context
func (t *Table) GetRecordsWithParamsContext(ctx context.Context, params url.Values) (*Records, error) {
records := new(Records)
err := t.client.get(ctx, t.dbName, t.tableName, "", params, records)
func (t *Table) GetRecordsWithParamsContext(ctx context.Context, params url.Values) ([]*Record, error) {
records, err := listAll[Record](ctx, t.client, t.dbName, t.tableName, params, "records")
if err != nil {
return nil, err
}
for _, record := range records.Records {
for _, record := range records {
record.client = t.client
record.table = t
}