-
Notifications
You must be signed in to change notification settings - Fork 100
Description
Summary
This issue requests the addition of comprehensive D1 database endpoint support to cloudflare-rs. Currently, the library only includes D1 bindings for Workers but lacks the database management endpoints needed for full D1 operations.
Background
D1 is Cloudflare's serverless SQL database service that provides SQLite-compatible databases with global distribution. While cloudflare-rs supports D1 bindings in the Workers module, it's missing the core database management functionality.
Missing Functionality
The following D1 API endpoints are currently not implemented:
Database Management
GET /accounts/{account_id}/d1/database
- List databasesPOST /accounts/{account_id}/d1/database
- Create databaseGET /accounts/{account_id}/d1/database/{database_id}
- Get database detailsDELETE /accounts/{account_id}/d1/database/{database_id}
- Delete databasePUT /accounts/{account_id}/d1/database/{database_id}
- Update databasePATCH /accounts/{account_id}/d1/database/{database_id}
- Partial update database
Data Operations
POST /accounts/{account_id}/d1/database/{database_id}/query
- Execute SQL queriesPOST /accounts/{account_id}/d1/database/{database_id}/raw
- Execute raw SQL queriesPOST /accounts/{account_id}/d1/database/{database_id}/export
- Export databasePOST /accounts/{account_id}/d1/database/{database_id}/import
- Import database
Proposed Solution
Implement a complete d1
endpoints module that provides:
- Database Management: Full CRUD operations for D1 databases
- Query Execution: Both parameterized and raw SQL query support
- Data Import/Export: Database backup and restore capabilities
- Configuration Management: Read replication and location hint support
- Comprehensive Testing: Full test coverage for all endpoints
- API Specification Compliance: 100% compliance with official OpenAPI spec
Implementation Details
- Follow existing cloudflare-rs patterns and conventions
- Use official Cloudflare OpenAPI specification as source of truth
- Implement proper error handling and response types
- Include comprehensive documentation and examples
- Maintain both blocking and async API support
Impact
This would fill a significant gap in cloudflare-rs functionality and enable developers to:
- Manage D1 databases programmatically from Rust applications
- Execute SQL queries and manage database schemas
- Implement automated backup/restore workflows
- Build complete database-driven applications on Cloudflare's platform
References
I have a complete implementation ready that follows all project conventions and passes comprehensive tests. I would be happy to submit a PR if this feature addition is welcomed.