Skip to content

Commit

Permalink
isolating production (master) environment db with my development or l…
Browse files Browse the repository at this point in the history
…egacy db environments

😀😀
  • Loading branch information
arnard76 committed Jul 29, 2023
1 parent 8711cc6 commit 2660e7d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/lib/exercises/CRUD/crudDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ import exercises from "$lib/exercises/store.js";
import type { ExercisesData, ExerciseData } from "$lib/exercises";

function updateExercise(exerciseId: string, updatedExercise: ExerciseData) {
set(ref(database, `development-db/${exerciseId}`), updatedExercise);
set(ref(database, `production-db/${exerciseId}`), updatedExercise);
}

function createExercise(exercise: ExerciseData) {
push(ref(database, `development-db/`), exercise);
push(ref(database, `production-db/`), exercise);
}

function duplicateExercise(exercise: ExerciseData) {
if (!exercise) return;
push(ref(database, `development-db/`), exercise);
push(ref(database, `production-db/`), exercise);
}

function deleteExercise(exerciseId: string) {
if (!exerciseId) return;

remove(ref(database, `development-db/${exerciseId}`));
remove(ref(database, `production-db/${exerciseId}`));
}

function streamExercises() {
return onValue(ref(database, `development-db/`), (snapshot) => {
return onValue(ref(database, `production-db/`), (snapshot) => {
const exerciseData: ExercisesData = snapshot.val();
console.log("exercises data:", exerciseData);
exercises.syncWithDatabase(exerciseData);
Expand Down

0 comments on commit 2660e7d

Please sign in to comment.