commit 60a5cecddce56036be2d0a950ae7ab819117a90c
parent 732ebe55cbccde47a14ebaece938234f9f41b955
Author: Silas Brack <silasbrack@gmail.com>
Date: Wed, 22 Apr 2026 08:19:36 +0200
fix: correct Trailbase API response format and migration naming
- Change ListResponse to use 'records' field instead of 'data'
- Rename migration to U100__ to avoid conflict with internal migrations
- Remove view from record_apis (views don't have primary keys)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat:
4 files changed, 15 insertions(+), 18 deletions(-)
diff --git a/src/trailbase.rs b/src/trailbase.rs
@@ -34,8 +34,8 @@ pub struct SearchResult {
#[derive(Debug, Deserialize)]
struct ListResponse<T> {
- data: Vec<T>,
- cursor: Option<String>,
+ records: Vec<T>,
+ total_count: i64,
}
#[derive(Debug, Serialize)]
@@ -78,7 +78,7 @@ impl TrailbaseClient {
self.base_url, limit, offset
);
let response: ListResponse<NewsItem> = self.client.get(&url).send().await?.json().await?;
- Ok(response.data)
+ Ok(response.records)
}
pub async fn get_news_by_category(
@@ -97,7 +97,7 @@ impl TrailbaseClient {
self.client.get(&url).send().await?.json().await?;
let news_ids: Vec<i64> = response
- .data
+ .records
.iter()
.filter_map(|v| v.get("news_item_id").and_then(|id| id.as_i64()))
.collect();
@@ -117,7 +117,7 @@ impl TrailbaseClient {
self.base_url, ids_filter, limit, offset
);
let response: ListResponse<NewsItem> = self.client.get(&url).send().await?.json().await?;
- Ok(response.data)
+ Ok(response.records)
}
pub async fn get_categories(&self, limit: i64) -> Result<Vec<Category>, reqwest::Error> {
@@ -126,7 +126,7 @@ impl TrailbaseClient {
self.base_url, limit
);
let response: ListResponse<Category> = self.client.get(&url).send().await?.json().await?;
- Ok(response.data)
+ Ok(response.records)
}
pub async fn get_categories_for_news(
@@ -141,7 +141,7 @@ impl TrailbaseClient {
self.client.get(&url).send().await?.json().await?;
let category_ids: Vec<i64> = response
- .data
+ .records
.iter()
.filter_map(|v| v.get("category_id").and_then(|id| id.as_i64()))
.collect();
@@ -160,7 +160,7 @@ impl TrailbaseClient {
self.base_url, ids_filter
);
let response: ListResponse<Category> = self.client.get(&url).send().await?.json().await?;
- Ok(response.data)
+ Ok(response.records)
}
pub async fn search_news(
@@ -177,7 +177,7 @@ impl TrailbaseClient {
);
let response: ListResponse<NewsItem> = self.client.get(&url).send().await?.json().await?;
Ok(response
- .data
+ .records
.into_iter()
.map(|n| SearchResult {
title: n.title,
diff --git a/traildepot/config.textproto b/traildepot/config.textproto
@@ -1,4 +1,4 @@
-# TrailBase config for simple-web-app
+# Auto-generated config.Config textproto
email {}
server {
application_name: "SimpleWebApp"
@@ -9,7 +9,6 @@ auth {
refresh_token_ttl_sec: 2592000
}
jobs {}
-
record_apis: [{
name: "news_item"
table_name: "news_item"
@@ -28,8 +27,4 @@ record_apis: [{
table_name: "news_item_category"
acl_world: [READ]
acl_authenticated: [READ, CREATE, DELETE]
-}, {
- name: "news_with_categories"
- table_name: "news_with_categories"
- acl_world: [READ]
-}]
+}]
+\ No newline at end of file
diff --git a/traildepot/metadata.textproto b/traildepot/metadata.textproto
@@ -1,2 +1,2 @@
-# Auto-generated metadata
-schema_version: 1
+# Auto-generated metadata.Metadata textproto
+last_executed_version: "v0.23.0-0-g65898fb"
+\ No newline at end of file
diff --git a/traildepot/migrations/main/U1_initial_schema.sql b/traildepot/migrations/main/U100__initial_schema.sql