86 lines
2.2 KiB
Markdown
86 lines
2.2 KiB
Markdown
# Ferrtable: Ferris the Crab's Favorite Airtable Client
|
|
|
|
A power vacuum churns where the venerable
|
|
[airtable-api](https://crates.io/crates/airtable-api) (archived but not
|
|
forgotten) once stood tall. The world calls for a new leader to carry the
|
|
fallen torch. From the dust rises Ferrtable: to abase SQL supremacy, to turn
|
|
all the tables, to rise inexorably to the top of the field, and to set the
|
|
record straight.
|
|
|
|
## Status: Work in Progress
|
|
|
|
Only a limited set of operations (e.g., creating and listing records) are
|
|
currently supported. The goal is to implement coverage for at least the full
|
|
set of non-enterprise API endpoints, but my initial emphasis is on getting a
|
|
relatively small subset built and tested well.
|
|
|
|
## Usage
|
|
|
|
```rust
|
|
use futures::prelude::*;
|
|
|
|
// Ferrtable allows us to use any record types that implement Clone,
|
|
// Deserialize, and Serialize.
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
struct MyRecord {
|
|
#[serde(rename = "Name")]
|
|
name: String,
|
|
|
|
#[serde(rename = "Notes")]
|
|
notes: String,
|
|
|
|
#[serde(rename = "Assignee")]
|
|
assignee: Option<String>,
|
|
|
|
#[serde(rename = "Status")]
|
|
status: Status,
|
|
|
|
#[serde(rename = "Attachments")]
|
|
attachments: Vec<ferrtable::cell_values::AttachmentRead>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
enum Status {
|
|
Todo,
|
|
|
|
#[serde(rename = "In progress")]
|
|
InProgress,
|
|
|
|
Done,
|
|
}
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
let client = ferrtable::Client::new_from_access_token("******").unwrap();
|
|
|
|
client
|
|
.create_records([MyRecord {
|
|
name: "Steal Improbability Drive".to_owned(),
|
|
notes: "Just for fun, no other reason.".to_owned(),
|
|
assignee: None,
|
|
status: Status::InProgress,
|
|
attachments: vec![],
|
|
}])
|
|
.with_base_id("***".to_owned())
|
|
.with_table_id("***".to_owned())
|
|
.build()
|
|
.unwrap()
|
|
.execute()
|
|
.await
|
|
.unwrap();
|
|
|
|
let mut rec_stream = client
|
|
.list_records()
|
|
.with_base_id("***".to_owned())
|
|
.with_table_id("***".to_owned())
|
|
.with_filter("{status} = 'Todo' || {status} = 'In Progress'".to_owned())
|
|
.build()
|
|
.unwrap()
|
|
.stream_items::<MyRecord>();
|
|
|
|
while let Some(result) = rec_stream.next().await {
|
|
let rec = result.unwrap();
|
|
dbg!(rec.fields);
|
|
}
|
|
}
|
|
```
|