2020-04-12 13:05:28 +03:00
|
|
|
package airtable
|
|
|
|
|
|
2023-01-12 12:54:18 +05:00
|
|
|
import (
|
|
|
|
|
"context"
|
2024-06-22 21:46:58 -07:00
|
|
|
"fmt"
|
2023-01-12 12:54:18 +05:00
|
|
|
)
|
2020-04-12 13:05:28 +03:00
|
|
|
|
|
|
|
|
type Record struct {
|
2023-07-09 22:33:45 +05:00
|
|
|
ID string `json:"id,omitempty"`
|
|
|
|
|
Fields map[string]any `json:"fields"`
|
|
|
|
|
CreatedTime string `json:"createdTime,omitempty"`
|
|
|
|
|
Deleted bool `json:"deleted,omitempty"`
|
2021-02-05 22:46:27 +03:00
|
|
|
|
2024-06-22 21:46:58 -07:00
|
|
|
c *Client
|
|
|
|
|
b *Base
|
|
|
|
|
t *Table
|
2020-04-12 13:05:28 +03:00
|
|
|
}
|
|
|
|
|
|
2024-06-22 21:46:58 -07:00
|
|
|
type ListRecordOptions struct {
|
2023-01-12 12:54:18 +05:00
|
|
|
}
|
|
|
|
|
|
2024-06-22 21:46:58 -07:00
|
|
|
func (t *Table) ListRecords(ctx context.Context, opts *ListRecordOptions) ([]*Record, error) {
|
|
|
|
|
return listAll[Record](ctx, t.c, fmt.Sprintf("%s/%s", t.b.ID, t.ID), nil, "records", func(r *Record) error {
|
|
|
|
|
r.c = t.c
|
|
|
|
|
r.b = t.b
|
|
|
|
|
r.t = t
|
|
|
|
|
return nil
|
|
|
|
|
})
|
2020-04-12 13:05:28 +03:00
|
|
|
}
|
|
|
|
|
|
2024-06-22 21:46:58 -07:00
|
|
|
func (r Record) String() string {
|
|
|
|
|
return r.Fields[r.t.Fields[0].Name].(string)
|
2020-04-12 13:05:28 +03:00
|
|
|
}
|