-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
222 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const currentConnection = localStorage.getItem("connection"); | ||
|
||
const config = { | ||
connection: currentConnection ?? "indexedDB", | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import model from "@/repositories/model"; | ||
import config from "@/configs/database"; | ||
|
||
const collection = model({ | ||
connection: config.connection, | ||
table: "collections", | ||
}); | ||
|
||
export default collection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<script setup> | ||
import { ref } from "vue"; | ||
import config from "@/configs/database"; | ||
const form = ref({ | ||
connection: config.connection, | ||
}); | ||
const submit = () => { | ||
localStorage.setItem("connection", form.value.connection); | ||
}; | ||
</script> | ||
<template> | ||
<div> | ||
<form @submit.prevent="submit" class="flex gap-2 flex-col"> | ||
<h1>Settings</h1> | ||
|
||
<select class="py-2 px-2 rounded-lg" v-model="form.connection"> | ||
<option value="indexedDB">IndexedDB</option> | ||
<option value="supabase">Supabase</option> | ||
</select> | ||
<button class="bg-dark-one text-white py-3 rounded-lg"> | ||
Save Changes | ||
</button> | ||
</form> | ||
</div> | ||
</template> | ||
|
||
<style lang="scss" scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import indexedDB from "./indexedDB"; | ||
import supabase from "./supabase"; | ||
import config from "@/configs/database"; | ||
/** | ||
* | ||
* @param {'indexedDB' | 'supabase'} connection | ||
* @param {string} table | ||
* @returns | ||
*/ | ||
const model = async ({ connection, table }) => { | ||
let store = null; | ||
|
||
console.log(connection, table); | ||
|
||
if (connection === "indexedDB") { | ||
store = indexedDB(table); | ||
} | ||
if (connection === "supabase") { | ||
store = supabase(table); | ||
} | ||
|
||
// Check if store is set | ||
if (!store) { | ||
throw new Error("Store not found."); | ||
} | ||
|
||
return { | ||
all: async () => { | ||
return await store.index(); | ||
}, | ||
find: (key) => { | ||
return store.find(key); | ||
}, | ||
create: (values) => { | ||
const data = store.create(values); | ||
return data; | ||
}, | ||
update: async (key, values) => { | ||
await store.update(key, values); | ||
}, | ||
delete: (key) => { | ||
store.delete(key); | ||
}, | ||
}; | ||
}; | ||
|
||
export default model; |
Oops, something went wrong.