From 97b7d42373b6b5a79b632ca89fbdd3cc55ed7ed1 Mon Sep 17 00:00:00 2001 From: maxitect Date: Tue, 10 Dec 2024 16:00:42 +0000 Subject: [PATCH 01/12] refactor: update category schema with string limits --- src/lib/db/schemas/categoriesSchema.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/db/schemas/categoriesSchema.json b/src/lib/db/schemas/categoriesSchema.json index 3bd9a27b..dd3f48f1 100644 --- a/src/lib/db/schemas/categoriesSchema.json +++ b/src/lib/db/schemas/categoriesSchema.json @@ -8,7 +8,8 @@ "maxLength": 100 }, "name": { - "type": "string" + "type": "string", + "maxLength": 255 }, "timestamp": { "type": "string", @@ -16,4 +17,4 @@ } }, "required": ["id", "name", "timestamp"] -} \ No newline at end of file +} From b1446749355d78389d2103316f16df4b8dccff43 Mon Sep 17 00:00:00 2001 From: maxitect Date: Tue, 10 Dec 2024 16:01:02 +0000 Subject: [PATCH 02/12] refactor: update toolkit item schema with string limits --- src/lib/db/schemas/toolkitItemSchema.json | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/lib/db/schemas/toolkitItemSchema.json b/src/lib/db/schemas/toolkitItemSchema.json index 6db9ca3b..0b4dcf5a 100644 --- a/src/lib/db/schemas/toolkitItemSchema.json +++ b/src/lib/db/schemas/toolkitItemSchema.json @@ -7,7 +7,10 @@ "type": "string", "maxLength": 100 }, - "name": { "type": "string" }, + "name": { + "type": "string", + "maxLength": 255 + }, "categories": { "type": "array", "items": { @@ -24,11 +27,5 @@ "format": "date-time" } }, - "required": [ - "id", - "name", - "categories", - "checked", - "timestamp" - ] -} \ No newline at end of file + "required": ["id", "name", "categories", "checked", "timestamp"] +} From 2ff55d637df0695930767d1acc0b541f84c8bdeb Mon Sep 17 00:00:00 2001 From: maxitect Date: Tue, 10 Dec 2024 16:01:48 +0000 Subject: [PATCH 03/12] chore: add needs category schema --- src/lib/db/schemas/needsCategoriesSchema.json | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/lib/db/schemas/needsCategoriesSchema.json diff --git a/src/lib/db/schemas/needsCategoriesSchema.json b/src/lib/db/schemas/needsCategoriesSchema.json new file mode 100644 index 00000000..77d2a2ab --- /dev/null +++ b/src/lib/db/schemas/needsCategoriesSchema.json @@ -0,0 +1,20 @@ +{ + "version": 0, + "primaryKey": "id", + "type": "object", + "properties": { + "id": { + "type": "string", + "maxLength": 100 + }, + "name": { + "type": "string", + "maxLength": 100 + }, + "timestamp": { + "type": "string", + "format": "date-time" + } + }, + "required": ["id", "name", "timestamp"] +} From dea4e7b92dbcfeb96e7b93f14f7f3abcc263c683 Mon Sep 17 00:00:00 2001 From: maxitect Date: Tue, 10 Dec 2024 16:03:02 +0000 Subject: [PATCH 04/12] chore: add needs schema --- src/lib/db/schemas/needsSchema.json | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/lib/db/schemas/needsSchema.json diff --git a/src/lib/db/schemas/needsSchema.json b/src/lib/db/schemas/needsSchema.json new file mode 100644 index 00000000..96e2b2ec --- /dev/null +++ b/src/lib/db/schemas/needsSchema.json @@ -0,0 +1,43 @@ +{ + "version": 0, + "primaryKey": "id", + "type": "object", + "properties": { + "id": { + "type": "string", + "maxLength": 100 + }, + "name": { + "type": "string", + "maxLength": 100 + }, + "selectedTimestamps": { + "type": "array", + "items": { + "type": "string", + "format": "date-time" + } + }, + "selectedExpiry": { + "type": "string", + "format": "date-time" + }, + "category": { + "type": "string", + "ref": "needs_categories", + "maxLength": 100 + }, + "timestamp": { + "type": "string", + "format": "date-time" + } + }, + "required": [ + "id", + "name", + "category", + "timestamp", + "selectedTimestamps", + "selectedExpiry" + ] +} From b7e4a9d345c4e2c3b1cb6da733c0d17014164c99 Mon Sep 17 00:00:00 2001 From: maxitect Date: Tue, 10 Dec 2024 16:03:18 +0000 Subject: [PATCH 05/12] chore: add next action schema --- src/lib/db/schemas/nextActionsSchema.json | 43 +++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/lib/db/schemas/nextActionsSchema.json diff --git a/src/lib/db/schemas/nextActionsSchema.json b/src/lib/db/schemas/nextActionsSchema.json new file mode 100644 index 00000000..95946ae9 --- /dev/null +++ b/src/lib/db/schemas/nextActionsSchema.json @@ -0,0 +1,43 @@ +{ + "version": 0, + "primaryKey": "id", + "type": "object", + "properties": { + "id": { + "type": "string", + "maxLength": 100 + }, + "name": { + "type": "string", + "maxLength": 255 + }, + "need": { + "type": "string", + "ref": "needs", + "maxLength": 100 + }, + "selectedTimestamps": { + "type": "array", + "items": { + "type": "string", + "format": "date-time" + } + }, + "selectedExpiry": { + "type": "string", + "format": "date-time" + }, + "timestamp": { + "type": "string", + "format": "date-time" + } + }, + "required": [ + "id", + "name", + "need", + "timestamp", + "selectedTimestamps", + "selectedExpiry" + ] +} From 1480f4b1f58ce14e3a8717b9d9a3a3801079cd75 Mon Sep 17 00:00:00 2001 From: maxitect Date: Tue, 10 Dec 2024 16:03:43 +0000 Subject: [PATCH 06/12] refactor: move toolkit seed data in own file --- src/lib/db/seed/toolkit.ts | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/lib/db/seed/toolkit.ts diff --git a/src/lib/db/seed/toolkit.ts b/src/lib/db/seed/toolkit.ts new file mode 100644 index 00000000..881f6ed5 --- /dev/null +++ b/src/lib/db/seed/toolkit.ts @@ -0,0 +1,55 @@ +import { v4 as uuidv4 } from "uuid"; + +export const categories = [ + { id: uuidv4(), name: "Replace", timestamp: new Date().toISOString() }, + { id: uuidv4(), name: "Barrier", timestamp: new Date().toISOString() }, + { id: uuidv4(), name: "Distract", timestamp: new Date().toISOString() }, + { + id: uuidv4(), + name: "Change Status", + timestamp: new Date().toISOString(), + }, +]; + +export const toolkit = [ + { + id: uuidv4(), + name: "Listen to my favourite music", + categories: ["Replace", "Barrier"], + checked: false, + infoUrl: "https://google.com/music", + imageUrl: + "https://daily.jstor.org/wp-content/uploads/2023/01/good_times_with_bad_music_1050x700.jpg", + timestamp: new Date().toISOString(), + }, + { + id: uuidv4(), + name: "Breathing exercises", + categories: ["Distract"], + checked: false, + infoUrl: "https://www.youtube.com/watch?v=DbDoBzGY3vo", + imageUrl: + "https://www.bhf.org.uk/-/media/images/information-support/heart-matters/2023/december/wellbeing/deep-breathing-620x400.png?h=400&w=620&rev=4506ebd34dab4476b56c225b6ff3ad60&hash=B3CFFEEE704E4432D101432CEE8B2766", + timestamp: new Date().toISOString(), + }, + { + id: uuidv4(), + name: "Call a friend", + categories: ["Distract", "Change status"], + checked: false, + infoUrl: "https://example.com/call", + imageUrl: + "https://t4.ftcdn.net/jpg/04/63/63/59/360_F_463635935_IweuYhCqZRtHp3SLguQL8svOVroVXvvZ.jpg", + timestamp: new Date().toISOString(), + }, + { + id: uuidv4(), + name: "Drink water", + categories: ["Distract", "Change status"], + checked: false, + infoUrl: "https://example.com/call", + imageUrl: + "https://content.health.harvard.edu/wp-content/uploads/2023/07/b8a1309a-ba53-48c7-bca3-9c36aab2338a.jpg", + timestamp: new Date().toISOString(), + }, +]; From 039a1ca6b3aa75b1a5b010db32c898e6e1f8ca0f Mon Sep 17 00:00:00 2001 From: maxitect Date: Tue, 10 Dec 2024 16:04:24 +0000 Subject: [PATCH 07/12] chore: prepare needs categories, needs and next actions data in needs.ts --- src/lib/db/seed/needs.ts | 154 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 src/lib/db/seed/needs.ts diff --git a/src/lib/db/seed/needs.ts b/src/lib/db/seed/needs.ts new file mode 100644 index 00000000..f177acd0 --- /dev/null +++ b/src/lib/db/seed/needs.ts @@ -0,0 +1,154 @@ +import { v4 as uuidv4 } from "uuid"; + +const categories = { + physicalNurturance: [ + "Air", + "Food", + "Water", + "Movement", + "Exercise", + "Protection (insects, bacteria, virus, predators)", + "Rest", + "Sexual expression", + "Shelter", + "Touch", + ], + play: ["Play", "Laughter"], + interdependence: [ + "Acceptance", + "Appreciation", + "Closeness", + "Community", + "Consideration", + "Contribution to the enrichment of life", + "Emotional safety", + "Empathy", + "Honesty", + "Love", + "Reassurance", + "Respect", + "Support", + "Trust", + "Understanding", + "Warmth", + ], + celebration: [ + "Celebration of life fulfilled", + "Celebration of dreams fulfilled", + "Mourning of dreams unfulfilled", + "Mourning losses of loved ones", + ], + harmony: ["Peace", "Order", "Harmony", "Beauty", "Inspiration"], + integrity: ["Authenticity", "Creativity", "Meaning", "Self worth"], + autonomy: [ + "Choose dreams", + "Choose goals", + "Choose values", + "Choose plan to fulfil dreams", + "Choose plan to fulfil goals", + "Choose plan to fulfil values", + ], +}; + +const normalize = (str: string) => + str + .toLowerCase() + .replace(/\s+/g, "") + .replace(/[^a-z0-9]/gi, ""); + +const capitalizeWords = (str: string) => + str.replace(/\b\w/g, (char) => char.toUpperCase()); + +const needsCategories = Object.keys(categories).map((key) => ({ + id: uuidv4(), + name: capitalizeWords(key.replace(/([A-Z])/g, " $1").trim()), + timestamp: new Date().toISOString(), +})); + +const needs = Object.entries(categories).flatMap(([categoryKey, items]) => { + const category = needsCategories.find( + (c) => normalize(c.name) === normalize(categoryKey) + ); + if (!category) throw new Error(`Category '${categoryKey}' not found`); + + return items.map((item) => ({ + id: uuidv4(), + name: item, + selectedTimestamps: [], + selectedExpiry: new Date().toISOString(), + category: category.id, + timestamp: new Date().toISOString(), + })); +}); + +const nextActions = needs.map((need) => { + const actionName = suggestAction(need.name); + return { + id: uuidv4(), + name: actionName, + need: need.id, + selectedTimestamps: [], + selectedExpiry: new Date().toISOString(), + timestamp: new Date().toISOString(), + }; +}); + +function suggestAction(needName: string): string { + const suggestions: Record = { + Air: "Find fresh air to breathe deeply.", + Food: "Prepare or purchase a nutritious meal.", + Water: "Drink a glass of water.", + Movement: "Stretch or take a short walk.", + Exercise: "Schedule time for a workout.", + "Protection (insects, bacteria, virus, predators)": + "Secure a safe environment.", + Rest: "Take a moment to relax and recharge.", + "Sexual expression": "Communicate openly about your needs.", + Shelter: "Ensure your space is clean and welcoming.", + Touch: "Reach out for a hug or comforting touch.", + Play: "Engage in a favorite game or activity.", + Laughter: "Watch something funny or joke with friends.", + Acceptance: "Practice self-acceptance through affirmations.", + Appreciation: "Express gratitude to someone you care about.", + Closeness: "Reach out to connect with a loved one.", + Community: "Participate in a group or social event.", + Consideration: "Take a moment to listen actively.", + "Contribution to the enrichment of life": + "Volunteer or offer help to someone in need.", + "Emotional safety": "Talk to a trusted friend about your feelings.", + Empathy: "Put yourself in someone else's shoes.", + Honesty: "Share your thoughts transparently.", + Love: "Spend quality time with someone close to you.", + Reassurance: "Ask for or provide encouragement.", + Respect: "Acknowledge someone's boundaries or contributions.", + Support: "Offer or ask for support from friends or family.", + Trust: "Engage in a trust-building activity.", + Understanding: "Seek to understand another's perspective.", + Warmth: "Create a cozy environment for yourself.", + "Celebration of life fulfilled": "Plan a small celebration.", + "Celebration of dreams fulfilled": + "Acknowledge and celebrate achievements.", + "Mourning of dreams unfulfilled": + "Reflect and journal about your emotions.", + "Mourning losses of loved ones": "Honor their memory in a meaningful way.", + Peace: "Meditate or spend time in a calm space.", + Order: "Organize your workspace or schedule.", + Harmony: "Seek resolution in lingering conflicts.", + Beauty: "Visit a place or object that inspires beauty.", + Inspiration: "Explore art or literature for new ideas.", + Authenticity: "Take a step that reflects your true self.", + Creativity: "Work on a creative project.", + Meaning: "Reflect on what gives you purpose.", + "Self worth": "Write a list of your positive attributes.", + "Choose dreams": "Visualize your ideal future.", + "Choose goals": "Set clear, actionable goals.", + "Choose values": "Identify your core values.", + "Choose plan to fulfil dreams": "Create a roadmap to achieve your dreams.", + "Choose plan to fulfil goals": "Break down your goals into steps.", + "Choose plan to fulfil values": "Act in alignment with your values.", + }; + + return suggestions[needName] || "Take a small step toward meeting this need."; +} + +export { needsCategories, needs, nextActions }; From 3af2b2e9b43d800d006c3c0a1f339b713709f0ea Mon Sep 17 00:00:00 2001 From: maxitect Date: Tue, 10 Dec 2024 16:06:13 +0000 Subject: [PATCH 08/12] feat: add collections for needs categories, needs and next actions along with seed data --- src/lib/db/DatabaseManager.ts | 59 +++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/src/lib/db/DatabaseManager.ts b/src/lib/db/DatabaseManager.ts index ba3822ff..5034a41b 100644 --- a/src/lib/db/DatabaseManager.ts +++ b/src/lib/db/DatabaseManager.ts @@ -5,8 +5,14 @@ import { createRxDatabase, RxDatabase } from "rxdb"; import toolkitItemSchema from "./schemas/toolkitItemSchema.json"; import moodRecordSchema from "./schemas/moodRecordSchema.json"; import categoriesSchema from "./schemas/categoriesSchema.json"; +import needsCategoriesSchema from "./schemas/categoriesSchema.json"; +import needsSchema from "./schemas/categoriesSchema.json"; +import nextActionsSchema from "./schemas/categoriesSchema.json"; import { v4 as uuidv4 } from "uuid"; +import { categories, toolkit } from "./seed/toolkit"; +import { needsCategories, needs, nextActions } from "./seed/needs"; + addRxPlugin(RxDBDevModePlugin); const seedData = { @@ -87,7 +93,14 @@ class DatabaseManager { ignoreDuplicate: true, }); - const requiredCollections = ["categories", "mood_records", "toolkit_items"]; + const requiredCollections = [ + "categories", + "mood_records", + "toolkit_items", + "needs_categories", + "needs", + "next_actions", + ]; const existingCollections = Object.keys(dbInstance.collections); for (const collection of requiredCollections) { @@ -99,7 +112,7 @@ class DatabaseManager { } } - console.log("Database initialized."); + console.log("Database initialised."); await this.seedDatabase(); return dbInstance; } @@ -109,7 +122,7 @@ class DatabaseManager { dbInstance = await this.createDatabase(); } if (!dbInstance) { - throw new Error("Failed to initialize the database."); + throw new Error("Failed to initialise the database."); } return dbInstance; } @@ -117,34 +130,26 @@ class DatabaseManager { private async seedDatabase() { console.log("Seeding database..."); try { - await this.seedCategories(); - await this.seedToolkitItems(); + await this.seed("categories", categories); + await this.seed("toolkit_items", toolkit); + await this.seed("needs_categories", needsCategories); + await this.seed("needs", needs); + await this.seed("next_actions", nextActions); } catch (error) { console.error("Error during database seeding:", error); } } - private async seedCategories() { - if (!dbInstance) throw new Error("Database not initialized."); - if (!dbInstance.collections.categories) { - throw new Error("Categories collection is missing."); - } - const existingDocs = await dbInstance.categories.find().exec(); - if (existingDocs.length === 0) { - console.log("Seeding categories..."); - await dbInstance.categories.bulkInsert(seedData.categories); - } - } + private async seed(collectionName: string, data: any[]) { + if (!dbInstance) throw new Error("Database not initialised."); + const collection = dbInstance.collections[collectionName]; + if (!collection) + throw new Error(`${collectionName} collection is missing.`); - private async seedToolkitItems() { - if (!dbInstance) throw new Error("Database not initialized."); - if (!dbInstance.collections.toolkit_items) { - throw new Error("Toolkit items collection is missing."); - } - const existingDocs = await dbInstance.toolkit_items.find().exec(); + const existingDocs = await collection.find().exec(); if (existingDocs.length === 0) { - console.log("Seeding toolkit items..."); - await dbInstance.toolkit_items.bulkInsert(seedData.toolkit); + console.log(`Seeding ${collectionName}...`); + await collection.bulkInsert(data); } } @@ -156,6 +161,12 @@ class DatabaseManager { return { schema: moodRecordSchema }; case "toolkit_items": return { schema: toolkitItemSchema }; + case "needs_categories": + return { schema: toolkitItemSchema }; + case "needs": + return { schema: toolkitItemSchema }; + case "next_actions": + return { schema: toolkitItemSchema }; default: throw new Error(`Unknown collection: ${collectionName}`); } From bb3a330206c2f895bc912e1479ecad21201b0502 Mon Sep 17 00:00:00 2001 From: maxitect Date: Tue, 10 Dec 2024 16:11:43 +0000 Subject: [PATCH 09/12] refactor: remove confusing seeding database log --- src/lib/db/DatabaseManager.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/db/DatabaseManager.ts b/src/lib/db/DatabaseManager.ts index 5034a41b..29314f38 100644 --- a/src/lib/db/DatabaseManager.ts +++ b/src/lib/db/DatabaseManager.ts @@ -128,7 +128,6 @@ class DatabaseManager { } private async seedDatabase() { - console.log("Seeding database..."); try { await this.seed("categories", categories); await this.seed("toolkit_items", toolkit); From f1f0066d0d63eca7714bd9d7ee4d3625e6d0dbb4 Mon Sep 17 00:00:00 2001 From: maxitect Date: Tue, 10 Dec 2024 16:24:39 +0000 Subject: [PATCH 10/12] refactor: change variable names to be clearer --- src/lib/db/seed/needs.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/db/seed/needs.ts b/src/lib/db/seed/needs.ts index f177acd0..9cc5e573 100644 --- a/src/lib/db/seed/needs.ts +++ b/src/lib/db/seed/needs.ts @@ -1,6 +1,6 @@ import { v4 as uuidv4 } from "uuid"; -const categories = { +const needsList = { physicalNurturance: [ "Air", "Food", @@ -50,24 +50,24 @@ const categories = { ], }; -const normalize = (str: string) => +const normalise = (str: string) => str .toLowerCase() .replace(/\s+/g, "") .replace(/[^a-z0-9]/gi, ""); -const capitalizeWords = (str: string) => +const capitaliseWords = (str: string) => str.replace(/\b\w/g, (char) => char.toUpperCase()); -const needsCategories = Object.keys(categories).map((key) => ({ +const needsCategories = Object.keys(needsList).map((key) => ({ id: uuidv4(), - name: capitalizeWords(key.replace(/([A-Z])/g, " $1").trim()), + name: capitaliseWords(key.replace(/([A-Z])/g, " $1").trim()), timestamp: new Date().toISOString(), })); -const needs = Object.entries(categories).flatMap(([categoryKey, items]) => { +const needs = Object.entries(needsList).flatMap(([categoryKey, items]) => { const category = needsCategories.find( - (c) => normalize(c.name) === normalize(categoryKey) + (c) => normalise(c.name) === normalise(categoryKey) ); if (!category) throw new Error(`Category '${categoryKey}' not found`); From 2d1047a0f05eb570126644bace71f6d0a3b5b559 Mon Sep 17 00:00:00 2001 From: maxitect Date: Tue, 10 Dec 2024 16:25:22 +0000 Subject: [PATCH 11/12] fix: pair correct schema with collection, refactor --- src/lib/db/DatabaseManager.ts | 64 +++-------------------------------- 1 file changed, 5 insertions(+), 59 deletions(-) diff --git a/src/lib/db/DatabaseManager.ts b/src/lib/db/DatabaseManager.ts index 29314f38..598128cd 100644 --- a/src/lib/db/DatabaseManager.ts +++ b/src/lib/db/DatabaseManager.ts @@ -2,74 +2,20 @@ import { addRxPlugin } from "rxdb"; import { RxDBDevModePlugin } from "rxdb/plugins/dev-mode"; import { getRxStorageDexie } from "rxdb/plugins/storage-dexie"; import { createRxDatabase, RxDatabase } from "rxdb"; +import { v4 as uuidv4 } from "uuid"; + import toolkitItemSchema from "./schemas/toolkitItemSchema.json"; import moodRecordSchema from "./schemas/moodRecordSchema.json"; import categoriesSchema from "./schemas/categoriesSchema.json"; import needsCategoriesSchema from "./schemas/categoriesSchema.json"; import needsSchema from "./schemas/categoriesSchema.json"; import nextActionsSchema from "./schemas/categoriesSchema.json"; -import { v4 as uuidv4 } from "uuid"; import { categories, toolkit } from "./seed/toolkit"; import { needsCategories, needs, nextActions } from "./seed/needs"; addRxPlugin(RxDBDevModePlugin); -const seedData = { - categories: [ - { id: uuidv4(), name: "Replace", timestamp: new Date().toISOString() }, - { id: uuidv4(), name: "Barrier", timestamp: new Date().toISOString() }, - { id: uuidv4(), name: "Distract", timestamp: new Date().toISOString() }, - { - id: uuidv4(), - name: "Change Status", - timestamp: new Date().toISOString(), - }, - ], - toolkit: [ - { - id: uuidv4(), - name: "Listen to my favourite music", - categories: ["Replace", "Barrier"], - checked: false, - infoUrl: "https://google.com/music", - imageUrl: - "https://daily.jstor.org/wp-content/uploads/2023/01/good_times_with_bad_music_1050x700.jpg", - timestamp: new Date().toISOString(), - }, - { - id: uuidv4(), - name: "Breathing exercises", - categories: ["Distract"], - checked: false, - infoUrl: "https://www.youtube.com/watch?v=DbDoBzGY3vo", - imageUrl: - "https://www.bhf.org.uk/-/media/images/information-support/heart-matters/2023/december/wellbeing/deep-breathing-620x400.png?h=400&w=620&rev=4506ebd34dab4476b56c225b6ff3ad60&hash=B3CFFEEE704E4432D101432CEE8B2766", - timestamp: new Date().toISOString(), - }, - { - id: uuidv4(), - name: "Call a friend", - categories: ["Distract", "Change status"], - checked: false, - infoUrl: "https://example.com/call", - imageUrl: - "https://t4.ftcdn.net/jpg/04/63/63/59/360_F_463635935_IweuYhCqZRtHp3SLguQL8svOVroVXvvZ.jpg", - timestamp: new Date().toISOString(), - }, - { - id: uuidv4(), - name: "Drink water", - categories: ["Distract", "Change status"], - checked: false, - infoUrl: "https://example.com/call", - imageUrl: - "https://content.health.harvard.edu/wp-content/uploads/2023/07/b8a1309a-ba53-48c7-bca3-9c36aab2338a.jpg", - timestamp: new Date().toISOString(), - }, - ], -}; - let dbInstance: RxDatabase | null = null; class DatabaseManager { @@ -161,11 +107,11 @@ class DatabaseManager { case "toolkit_items": return { schema: toolkitItemSchema }; case "needs_categories": - return { schema: toolkitItemSchema }; + return { schema: needsCategoriesSchema }; case "needs": - return { schema: toolkitItemSchema }; + return { schema: needsSchema }; case "next_actions": - return { schema: toolkitItemSchema }; + return { schema: nextActionsSchema }; default: throw new Error(`Unknown collection: ${collectionName}`); } From 36d727dbef2ce29cf759071c7d7d713c41c6744d Mon Sep 17 00:00:00 2001 From: maxitect Date: Tue, 10 Dec 2024 16:42:27 +0000 Subject: [PATCH 12/12] fix: change data type for seed method in DatabaseManager.ts --- src/lib/db/DatabaseManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/db/DatabaseManager.ts b/src/lib/db/DatabaseManager.ts index 598128cd..a6425856 100644 --- a/src/lib/db/DatabaseManager.ts +++ b/src/lib/db/DatabaseManager.ts @@ -85,7 +85,7 @@ class DatabaseManager { } } - private async seed(collectionName: string, data: any[]) { + private async seed(collectionName: string, data: T[]) { if (!dbInstance) throw new Error("Database not initialised."); const collection = dbInstance.collections[collectionName]; if (!collection)