[PR #190] [MERGED] Database access refactor #115

Closed
opened 2025-12-29 07:19:24 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mountain-loop/yaak/pull/190
Author: @gschier
Created: 3/23/2025
Status: Merged
Merged: 3/25/2025
Merged by: @gschier

Base: masterHead: db-refactor


📝 Commits (10+)

📊 Changes

72 files changed (+4891 additions, -4698 deletions)

View changed files

📝 package-lock.json (+124 -108)
📝 package.json (+4 -4)
📝 packages/plugin-runtime-types/package.json (+1 -3)
📝 packages/plugin-runtime/src/PluginHandle.ts (+0 -1)
📝 src-tauri/Cargo.lock (+183 -277)
📝 src-tauri/Cargo.toml (+3 -3)
📝 src-tauri/gen/schemas/acl-manifests.json (+1 -1)
📝 src-tauri/gen/schemas/desktop-schema.json (+88 -3)
📝 src-tauri/gen/schemas/macOS-schema.json (+88 -3)
📝 src-tauri/src/error.rs (+10 -7)
📝 src-tauri/src/history.rs (+20 -28)
📝 src-tauri/src/http_request.rs (+43 -19)
📝 src-tauri/src/lib.rs (+558 -543)
📝 src-tauri/src/notifications.rs (+21 -5)
📝 src-tauri/src/plugin_events.rs (+74 -30)
📝 src-tauri/src/updates.rs (+32 -26)
📝 src-tauri/yaak-git/Cargo.toml (+2 -2)
📝 src-tauri/yaak-git/permissions/schemas/schema.json (+2 -2)
📝 src-tauri/yaak-license/permissions/schemas/schema.json (+2 -2)
📝 src-tauri/yaak-license/src/commands.rs (+4 -4)

...and 52 more files

📄 Description

This PR introduces a new DB access pattern to query data by app_handle.queries().connect()?.get_workspace() but also has the ability to do transactions and includes easy ways to write common queries.

impl<'a> DbContext<'a> {
    pub fn list_http_requests(&self, workspace_id: &str) -> Result<Vec<HttpRequest>> {
        Ok(self.find_many(Table, WorkspaceId, workspace_id, None)?)
    }
}
  • Define trait for Tauri Manager to expose queries()
  • Implement queries connect() and with_tx() helpers
  • Add model_upserted and model_deleted events
  • Decide whether or not to use tokio or std Mutex for DB connection
  • Implement upsert/delete model plugin commands
  • Port all frontend stuff to new commands
  • Port all backend queries to new query manager

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mountain-loop/yaak/pull/190 **Author:** [@gschier](https://github.com/gschier) **Created:** 3/23/2025 **Status:** ✅ Merged **Merged:** 3/25/2025 **Merged by:** [@gschier](https://github.com/gschier) **Base:** `master` ← **Head:** `db-refactor` --- ### 📝 Commits (10+) - [`6fc710d`](https://github.com/mountain-loop/yaak/commit/6fc710de6cbd0f9d6da572bbc53ad75f1bcd1302) Checkpoint - [`38d34a3`](https://github.com/mountain-loop/yaak/commit/38d34a33cb234a9184d2766616d335569fe05c8f) A bit better - [`5f0200a`](https://github.com/mountain-loop/yaak/commit/5f0200a5d0d0b9c2dff4efec1a5dbd9df5669402) It's working! - [`9375435`](https://github.com/mountain-loop/yaak/commit/93754357ccec1bc4a6d0ff1b56f0ec792e7eb407) Checkpoint - [`cd32a09`](https://github.com/mountain-loop/yaak/commit/cd32a091950edf917c08b982c783e3e4f807b941) Generic upsert and deletion - [`fb0165d`](https://github.com/mountain-loop/yaak/commit/fb0165d919fa58eafe20445cf6ac567e94c41ca0) Macro to generate AnyModel enum - [`5b613f5`](https://github.com/mountain-loop/yaak/commit/5b613f52d25ca43af24057ee6ebdbbe1f0cbc9fb) Remove some plugin logs - [`4084e5f`](https://github.com/mountain-loop/yaak/commit/4084e5f3d9075e840264eca4f57ea67e9fdde3a1) Rename queries_2 mod - [`65df7f5`](https://github.com/mountain-loop/yaak/commit/65df7f5156998cfca93232f20f2ddc298ab83f2b) Tokio-friendly QueryManager - [`07cfc20`](https://github.com/mountain-loop/yaak/commit/07cfc20c2336d87f17241472617f8d823aadca8b) Move over workspace queries and other things ### 📊 Changes **72 files changed** (+4891 additions, -4698 deletions) <details> <summary>View changed files</summary> 📝 `package-lock.json` (+124 -108) 📝 `package.json` (+4 -4) 📝 `packages/plugin-runtime-types/package.json` (+1 -3) 📝 `packages/plugin-runtime/src/PluginHandle.ts` (+0 -1) 📝 `src-tauri/Cargo.lock` (+183 -277) 📝 `src-tauri/Cargo.toml` (+3 -3) 📝 `src-tauri/gen/schemas/acl-manifests.json` (+1 -1) 📝 `src-tauri/gen/schemas/desktop-schema.json` (+88 -3) 📝 `src-tauri/gen/schemas/macOS-schema.json` (+88 -3) 📝 `src-tauri/src/error.rs` (+10 -7) 📝 `src-tauri/src/history.rs` (+20 -28) 📝 `src-tauri/src/http_request.rs` (+43 -19) 📝 `src-tauri/src/lib.rs` (+558 -543) 📝 `src-tauri/src/notifications.rs` (+21 -5) 📝 `src-tauri/src/plugin_events.rs` (+74 -30) 📝 `src-tauri/src/updates.rs` (+32 -26) 📝 `src-tauri/yaak-git/Cargo.toml` (+2 -2) 📝 `src-tauri/yaak-git/permissions/schemas/schema.json` (+2 -2) 📝 `src-tauri/yaak-license/permissions/schemas/schema.json` (+2 -2) 📝 `src-tauri/yaak-license/src/commands.rs` (+4 -4) _...and 52 more files_ </details> ### 📄 Description This PR introduces a new DB access pattern to query data by `app_handle.queries().connect()?.get_workspace()` but also has the ability to do transactions and includes easy ways to write common queries. ```rust impl<'a> DbContext<'a> { pub fn list_http_requests(&self, workspace_id: &str) -> Result<Vec<HttpRequest>> { Ok(self.find_many(Table, WorkspaceId, workspace_id, None)?) } } ``` - [x] Define trait for Tauri Manager to expose `queries()` - [x] Implement queries `connect()` and `with_tx()` helpers - [x] Add `model_upserted` and `model_deleted` events - [x] Decide whether or not to use tokio or std `Mutex` for DB connection - [ ] Implement upsert/delete model plugin commands - [ ] Port all frontend stuff to new commands - [x] Port all backend queries to new query manager --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 07:19:24 +01:00
adam closed this issue 2025-12-29 07:19:24 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/yaak#115