[PR #4804] [CLOSED] [Enhancement] Refactor loot-core db queries into separate entity queries and mutations #83270

Closed
opened 2026-05-19 08:00:47 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/4804
Author: @koonweee
Created: 4/13/2025
Status: ❌ Closed

Base: master ← Head: jt/refactor-db-helpers-queries-mutations


📝 Commits (4)

  • 0adca4a Refactor loot-core db queries into separate entity queries and mutations
  • 905c347 Release notes
  • a1b20c3 Lint fix
  • ad74b40 Fix typecheck

📊 Changes

18 files changed (+826 additions, -804 deletions)

View changed files

📝 packages/loot-core/src/server/db/__snapshots__/db.test.ts.snap (+0 -0)
📝 packages/loot-core/src/server/db/db.test.ts (+1 -1)
➕ packages/loot-core/src/server/db/db.ts (+281 -0)
📝 packages/loot-core/src/server/db/index.ts (+4 -801)
📝 packages/loot-core/src/server/db/mappings.ts (+1 -1)
➕ packages/loot-core/src/server/db/mutations/accounts.ts (+57 -0)
➕ packages/loot-core/src/server/db/mutations/categories.ts (+191 -0)
➕ packages/loot-core/src/server/db/mutations/index.ts (+4 -0)
➕ packages/loot-core/src/server/db/mutations/payees.ts (+81 -0)
➕ packages/loot-core/src/server/db/mutations/transactions.ts (+14 -0)
➕ packages/loot-core/src/server/db/queries/accounts.ts (+20 -0)
➕ packages/loot-core/src/server/db/queries/categories.ts (+48 -0)
➕ packages/loot-core/src/server/db/queries/index.ts (+4 -0)
➕ packages/loot-core/src/server/db/queries/payees.ts (+80 -0)
➕ packages/loot-core/src/server/db/queries/transactions.ts (+25 -0)
📝 packages/loot-core/src/server/db/util.ts (+8 -0)
📝 packages/loot-core/src/server/transactions/transfer.test.ts (+1 -1)
➕ upcoming-release-notes/4804.md (+6 -0)

📄 Description

Changes

This PR addresses a comment in loot-core's db/index.ts suggesting that functions performing queries and mutations on the different entity types should be refactored into their own files. This should help with dev-ex for future contributors.

  • Refactored entity specific functions in db/index.ts into db/mutations/<entity-name>.ts and db/queries/<entity-name>.ts
    • eg. db/mutations/payees.ts, db/mutations/transactions.ts
  • Renamed db/index.ts to db/db.ts since it contains db specific logic
  • Updated db/index.ts to be an entrypoint for db.ts and all queries and mutations

🔄 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/actualbudget/actual/pull/4804 **Author:** [@koonweee](https://github.com/koonweee) **Created:** 4/13/2025 **Status:** ❌ Closed **Base:** `master` ← **Head:** `jt/refactor-db-helpers-queries-mutations` --- ### 📝 Commits (4) - [`0adca4a`](https://github.com/actualbudget/actual/commit/0adca4a2e0b49b929f69b4dbeb80a7b56f86b25f) Refactor loot-core db queries into separate entity queries and mutations - [`905c347`](https://github.com/actualbudget/actual/commit/905c34785b97d2da759211479b076d4a9a46b63b) Release notes - [`a1b20c3`](https://github.com/actualbudget/actual/commit/a1b20c30083194284483a7c1d15d1d4aa8520fb0) Lint fix - [`ad74b40`](https://github.com/actualbudget/actual/commit/ad74b40915daf3afdfdd627dd0bda950f4c4ad56) Fix typecheck ### 📊 Changes **18 files changed** (+826 additions, -804 deletions) <details> <summary>View changed files</summary> 📝 `packages/loot-core/src/server/db/__snapshots__/db.test.ts.snap` (+0 -0) 📝 `packages/loot-core/src/server/db/db.test.ts` (+1 -1) ➕ `packages/loot-core/src/server/db/db.ts` (+281 -0) 📝 `packages/loot-core/src/server/db/index.ts` (+4 -801) 📝 `packages/loot-core/src/server/db/mappings.ts` (+1 -1) ➕ `packages/loot-core/src/server/db/mutations/accounts.ts` (+57 -0) ➕ `packages/loot-core/src/server/db/mutations/categories.ts` (+191 -0) ➕ `packages/loot-core/src/server/db/mutations/index.ts` (+4 -0) ➕ `packages/loot-core/src/server/db/mutations/payees.ts` (+81 -0) ➕ `packages/loot-core/src/server/db/mutations/transactions.ts` (+14 -0) ➕ `packages/loot-core/src/server/db/queries/accounts.ts` (+20 -0) ➕ `packages/loot-core/src/server/db/queries/categories.ts` (+48 -0) ➕ `packages/loot-core/src/server/db/queries/index.ts` (+4 -0) ➕ `packages/loot-core/src/server/db/queries/payees.ts` (+80 -0) ➕ `packages/loot-core/src/server/db/queries/transactions.ts` (+25 -0) 📝 `packages/loot-core/src/server/db/util.ts` (+8 -0) 📝 `packages/loot-core/src/server/transactions/transfer.test.ts` (+1 -1) ➕ `upcoming-release-notes/4804.md` (+6 -0) </details> ### 📄 Description <!-- Thank you for submitting a pull request! Make sure to follow the instructions to write release notes for your PR — it should only take a minute or two: https://github.com/actualbudget/docs#writing-good-release-notes. Try running yarn generate:release-notes *before* pushing your PR for an interactive experience. --> ## Changes This PR addresses a comment in `loot-core`'s `db/index.ts` suggesting that functions performing queries and mutations on the different entity types should be refactored into their own files. This should help with dev-ex for future contributors. * Refactored entity specific functions in `db/index.ts` into `db/mutations/<entity-name>.ts` and `db/queries/<entity-name>.ts` * eg. `db/mutations/payees.ts`, `db/mutations/transactions.ts` * Renamed `db/index.ts` to `db/db.ts` since it contains db specific logic * Updated `db/index.ts` to be an entrypoint for `db.ts` and all queries and mutations --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-19 08:00:47 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#83270