1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//! Data operation routes
//!
//! Provides REST endpoints for CRUD operations on table data.
use ;
use crate;
/// Create data operation routes
///
/// # Endpoints
///
/// - `GET /v1/branches/:name/tables` - List all tables in a branch
/// - `GET /v1/branches/:name/tables/:table/data` - Query table data with pagination and filtering
/// - `POST /v1/branches/:name/tables/:table/data` - Insert data into a table
/// - `PUT /v1/branches/:name/tables/:table/data` - Update data in a table
/// - `DELETE /v1/branches/:name/tables/:table/data` - Delete data from a table
///
/// # Query Parameters (for GET)
///
/// - `filter`: WHERE clause filter (optional)
/// - `columns`: Comma-separated column names (optional, defaults to *)
/// - `page`: Page number, 1-based (optional, default: 1)
/// - `limit`: Page size (optional, default: 100, max: 1000)
/// - `as_of`: Time-travel timestamp (optional)
/// - `order_by`: ORDER BY clause (optional)
///
/// # Examples
///
/// ```bash
/// # List all tables in main branch
/// curl http://localhost:8080/v1/branches/main/tables
///
/// # Query all data from a table
/// curl http://localhost:8080/v1/branches/main/tables/users/data
///
/// # Query with filter and pagination
/// curl "http://localhost:8080/v1/branches/main/tables/users/data?filter=age>25&page=1&limit=10"
///
/// # Query specific columns
/// curl "http://localhost:8080/v1/branches/main/tables/users/data?columns=id,name,email"
///
/// # Time-travel query (as of timestamp)
/// curl "http://localhost:8080/v1/branches/main/tables/users/data?as_of=1234567890"
///
/// # Insert data
/// curl -X POST http://localhost:8080/v1/branches/main/tables/users/data \
/// -H "Content-Type: application/json" \
/// -d '{"rows": [{"id": 1, "name": "Alice", "email": "alice@example.com"}]}'
///
/// # Update data
/// curl -X PUT http://localhost:8080/v1/branches/main/tables/users/data \
/// -H "Content-Type: application/json" \
/// -d '{"values": {"email": "newemail@example.com"}, "filter": "id = 1"}'
///
/// # Delete data
/// curl -X DELETE http://localhost:8080/v1/branches/main/tables/users/data \
/// -H "Content-Type: application/json" \
/// -d '{"filter": "id = 1"}'
/// ```