[PR #83] [CLOSED] Refactor db/index into multiple files. #3008

Closed
opened 2026-02-28 20:34:56 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/83
Author: @TomAFrench
Created: 6/1/2022
Status: Closed

Base: masterHead: db-refactor


📝 Commits (10+)

  • 848ee21 refactor: break out data specific functions into different files
  • dba702c refactor: move any code directly interacting with db into db-connection.js
  • 0c64e73 refactor: move generic db operations into db-actions
  • a885f63 refactor: move loadClock into clock file
  • f476324 style: run prettier
  • 9c2c982 test: move tests to cover subfiles
  • 0c66dd4 refactor: replace let with const where appropriate
  • 4650edb refactor: improve variable name
  • 1c4c12e chore: remove unwanted comment
  • 63b21e4 refactor: reorder functions

📊 Changes

13 files changed (+729 additions, -708 deletions)

View changed files

📝 packages/loot-core/src/server/db/__snapshots__/transactions.test.js.snap (+0 -0)
packages/loot-core/src/server/db/accounts.js (+96 -0)
packages/loot-core/src/server/db/categories.js (+153 -0)
packages/loot-core/src/server/db/categories.test.js (+14 -0)
packages/loot-core/src/server/db/clock.js (+28 -0)
packages/loot-core/src/server/db/db-actions.js (+160 -0)
packages/loot-core/src/server/db/db-connection.js (+60 -0)
📝 packages/loot-core/src/server/db/index.js (+7 -677)
📝 packages/loot-core/src/server/db/mappings.js (+3 -3)
packages/loot-core/src/server/db/payees.js (+137 -0)
packages/loot-core/src/server/db/transactions.js (+50 -0)
📝 packages/loot-core/src/server/db/transactions.test.js (+19 -26)
📝 packages/loot-core/src/server/db/util.js (+2 -2)

📄 Description

db/index is pretty huge with a mix of management of the database connection along with business logic (adding transactions and payees, etc.). As mentioned in the code it's a good idea to break this out into multiple files.

b4696ce598/packages/loot-core/src/server/db/index.js (L260-L261)

This PR performs this refactoring while maintaining the same exports from db/index so it should have no effect beyond this folder.


🔄 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/83 **Author:** [@TomAFrench](https://github.com/TomAFrench) **Created:** 6/1/2022 **Status:** ❌ Closed **Base:** `master` ← **Head:** `db-refactor` --- ### 📝 Commits (10+) - [`848ee21`](https://github.com/actualbudget/actual/commit/848ee217c717de2e921fabf9cc141150eac9a299) refactor: break out data specific functions into different files - [`dba702c`](https://github.com/actualbudget/actual/commit/dba702c8df26b652ecbcc9fe2943ac928769f52a) refactor: move any code directly interacting with `db` into db-connection.js - [`0c64e73`](https://github.com/actualbudget/actual/commit/0c64e737d60f29e8e1436efff8e21168cf8daa1c) refactor: move generic db operations into db-actions - [`a885f63`](https://github.com/actualbudget/actual/commit/a885f6379dd8d0fae1f705f1767ffe441cbaeb6a) refactor: move loadClock into `clock` file - [`f476324`](https://github.com/actualbudget/actual/commit/f476324f621b79472a61fbb3603ec91df2d7e1f8) style: run prettier - [`9c2c982`](https://github.com/actualbudget/actual/commit/9c2c98256a49af3fffa0fcc67f2c2b406bd82650) test: move tests to cover subfiles - [`0c66dd4`](https://github.com/actualbudget/actual/commit/0c66dd4d2e5db766a27e4b2a724e72e182970393) refactor: replace let with const where appropriate - [`4650edb`](https://github.com/actualbudget/actual/commit/4650edb992018b896d602428008b95d2046738b3) refactor: improve variable name - [`1c4c12e`](https://github.com/actualbudget/actual/commit/1c4c12e9488545cb449b5c774397d8e8155c9f53) chore: remove unwanted comment - [`63b21e4`](https://github.com/actualbudget/actual/commit/63b21e42ae1048efa4e02b4458c5ed8afb9b1c06) refactor: reorder functions ### 📊 Changes **13 files changed** (+729 additions, -708 deletions) <details> <summary>View changed files</summary> 📝 `packages/loot-core/src/server/db/__snapshots__/transactions.test.js.snap` (+0 -0) ➕ `packages/loot-core/src/server/db/accounts.js` (+96 -0) ➕ `packages/loot-core/src/server/db/categories.js` (+153 -0) ➕ `packages/loot-core/src/server/db/categories.test.js` (+14 -0) ➕ `packages/loot-core/src/server/db/clock.js` (+28 -0) ➕ `packages/loot-core/src/server/db/db-actions.js` (+160 -0) ➕ `packages/loot-core/src/server/db/db-connection.js` (+60 -0) 📝 `packages/loot-core/src/server/db/index.js` (+7 -677) 📝 `packages/loot-core/src/server/db/mappings.js` (+3 -3) ➕ `packages/loot-core/src/server/db/payees.js` (+137 -0) ➕ `packages/loot-core/src/server/db/transactions.js` (+50 -0) 📝 `packages/loot-core/src/server/db/transactions.test.js` (+19 -26) 📝 `packages/loot-core/src/server/db/util.js` (+2 -2) </details> ### 📄 Description [`db/index`](https://github.com/actualbudget/actual/blob/master/packages/loot-core/src/server/db/index.js) is pretty huge with a mix of management of the database connection along with business logic (adding transactions and payees, etc.). As mentioned in the code it's a good idea to break this out into multiple files. https://github.com/actualbudget/actual/blob/b4696ce5989a79065f6ef30dd32cff7e59044852/packages/loot-core/src/server/db/index.js#L260-L261 This PR performs this refactoring while maintaining the same exports from `db/index` so it should have no effect beyond this folder. --- <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-02-28 20:34:56 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#3008