From ed16527e8720cdd9f79f09c51296c704a6f36595 Mon Sep 17 00:00:00 2001 From: Joy <138333978+joypan1@users.noreply.github.com> Date: Thu, 14 Mar 2024 12:10:16 -0400 Subject: [PATCH] added new db table, matches, changed db version for changes to have effect --- index.js | 8 +++++++- pages/matchinfo.js | 14 ++++++++++---- pages/teamdetails.js | 7 ++++++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 673b6b1..f90f89b 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,12 @@ const db = new Dexie("Team Tracking App"); //trap was in there twice throwing errors so I removed the last one of them (2nd to last entry) -db.version(1).stores({ teams: "++id, teamname, globalid, rank, teamnumber, teamschool, alliancescore, moreinfo, startingpos, Leaveszone, scores1amp, scores1speaker, picksup, scores2amp, scores2speaker, preferredScoringMethod, preferredIntakeMethod, prefintake, spotlight, trap, alone, hangsWithAnother, attemptsSpotlight, coop, matchnumber, count1, count2, count3, count4, count5, count6, count7, stage, hangs, harmony, otherinfo" }); + +db.version(2).stores({ + teams: "++id, teamname, globalid, teamnumber, teamschool, alliancescore, moreinfo, startingpos, Leaveszone, scores1amp, scores1speaker, picksup, scores2amp, scores2speaker, preferredScoringMethod, preferredIntakeMethod, prefintake, spotlight, trap, alone, hangsWithAnother, attemptsSpotlight, coop", + matches: "++id, rank, matchnumber, count1, count2, count3, count4, count5, count6, count7, stage, hangs, harmony, otherinfo" +}); + // Version numbers must be changed whenever database objects (schema) are edited? See "Modify Schema" in https://dexie.org/docs/Tutorial/Understanding-the-basics + const form = document.querySelector("#new-team-form"); const input = document.querySelector("#new-team-input"); diff --git a/pages/matchinfo.js b/pages/matchinfo.js index 72f63d1..5ac44ed 100644 --- a/pages/matchinfo.js +++ b/pages/matchinfo.js @@ -143,9 +143,13 @@ plusBtn7.addEventListener('click', function() { // DATABASE --------------------------------------------------------------- const db = new Dexie("Team Tracking App"); -db.version(1).stores({ teams: "++id, teamname, globalid, rank, teamnumber, teamschool, alliancescore, moreinfo, startingpos, Leaveszone, scores1amp, scores1speaker, picksup, scores2amp, scores2speaker, preferredScoringMethod, preferredIntakeMethod, prefintake, spotlight, trap, alone, hangsWithAnother, attemptsSpotlight, coop, matchnumber, count1, count2, count3, count4, count5, count6, count7, stage, hangs, harmony, trap, otherinfo"}); -// db = database -// teams = table in database db +db.version(2).stores({ + teams: "++id, teamname, globalid, teamnumber, teamschool, alliancescore, moreinfo, startingpos, Leaveszone, scores1amp, scores1speaker, picksup, scores2amp, scores2speaker, preferredScoringMethod, preferredIntakeMethod, prefintake, spotlight, trap, alone, hangsWithAnother, attemptsSpotlight, coop", + matches: "++id, rank, matchnumber, count1, count2, count3, count4, count5, count6, count7, stage, hangs, harmony, otherinfo" +}); + // Version numbers must be changed whenever database objects (schema) are edited? See "Modify Schema" in https://dexie.org/docs/Tutorial/Understanding-the-basics + // db = database + // teams = table in database db /* Steps to submitting data (theoretically) 1. Input information in match form, press the submit button @@ -163,7 +167,9 @@ const teamnumber = document.getElementById("teamnumber").value; // in order to submit match data for a specific team from the general match info page, // you need to get the globalid of an existing, matching team entry with the teamnumber submitted on matchinfo.html? -//const globalid = ???? +const teamsDB = db.teams.toArray(); +console.log(teamsDB); +//const globalid = ; //insert team data diff --git a/pages/teamdetails.js b/pages/teamdetails.js index fb8c23d..5d8b42a 100644 --- a/pages/teamdetails.js +++ b/pages/teamdetails.js @@ -1,6 +1,11 @@ // Global Dexie database initialization const db = new Dexie("Team Tracking App"); -db.version(1).stores({ teams: "++id, teamname, globalid, rank, teamnumber, teamschool, alliancescore, moreinfo, startingpos, Leaveszone, scores1amp, scores1speaker, picksup, scores2amp, scores2speaker, preferredScoringMethod, preferredIntakeMethod, prefintake, spotlight, trap, alone, hangsWithAnother, attemptsSpotlight, coop, matchnumber, count1, count2, count3, count4, count5, count6, count7, stage, hangs, harmony, otherinfo" }); +db.version(2).stores({ + teams: "++id, teamname, globalid, teamnumber, teamschool, alliancescore, moreinfo, startingpos, Leaveszone, scores1amp, scores1speaker, picksup, scores2amp, scores2speaker, preferredScoringMethod, preferredIntakeMethod, prefintake, spotlight, trap, alone, hangsWithAnother, attemptsSpotlight, coop", + matches: "++id, rank, matchnumber, count1, count2, count3, count4, count5, count6, count7, stage, hangs, harmony, otherinfo" +}); + // Version numbers must be changed whenever database objects (schema) are edited? See "Modify Schema" in https://dexie.org/docs/Tutorial/Understanding-the-basics + document.addEventListener('DOMContentLoaded', async () => { try {