Skip to content

Commit

Permalink
Merge pull request #13 from retrouser955/master
Browse files Browse the repository at this point in the history
Create a plugin and user store
  • Loading branch information
ItsLimeNade authored Apr 3, 2024
2 parents 3232ab8 + e5a0fcf commit 91448ba
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
46 changes: 44 additions & 2 deletions src/lib/utils/localDB/localDBmanager.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,53 @@
export default class LocalDBManager {
import { Dexie, type Table } from "dexie";

export default class LocalDBManager extends Dexie {
plugins!: Table<DiscodesPluginDataStore, string>
users!: Table<User, string>

constructor() {
super("DiscodesDatabase")

this.version(1).stores({
plugins: "id",
users: "id"
})
}

async getPlugin(id: string) {
const val = await this.plugins.get(id)

if(!val) return undefined

const ownerId = val.owner
const owner = await this.users.get(ownerId)

if(!owner) return undefined

const obj: DiscodesPlugin = {
...val,
owner
}

return obj
}
}

//TODO Make those interfaces!
//? Some data are for the backend only, if you feel like it doesn't belong in the localDB don't add them! Thx <3
type BlockConfig = unknown;

type DiscodesPluginDataStore = {
id: string,
name: string
owner: string
description: string
downloads: number
likes: number
rating: number
version: number
blocks: BlockConfig[]
}

type DiscodesPlugin = {
id: string,
owner: User
Expand All @@ -25,7 +67,7 @@ type User = {
followers: User[]
createdAt: Date
workspaces: DiscodesWorkspace[]
publishedPluins: DiscodesPlugin[]
publishedPlugins: DiscodesPlugin[]
publishedExamples: DiscodesFile[]
}

Expand Down
2 changes: 1 addition & 1 deletion tests/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test } from "@playwright/test";
import { test } from "@playwright/test";

test("index page has expected h1", async({ page }) => {
await page.goto("/");
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,11 @@ devalue@^4.3.2:
resolved "https://registry.npmjs.org/devalue/-/devalue-4.3.2.tgz#cc44e4cf3872ac5a78229fbce3b77e57032727b5"
integrity sha512-KqFl6pOgOW+Y6wJgu80rHpo2/3H07vr8ntR9rkkFIRETewbf5GaYYcakYfiKz89K+sLsuPkQIZaXDMjUObZwWg==

dexie@^4.0.1:
version "4.0.1"
resolved "https://registry.npmjs.org/dexie/-/dexie-4.0.1.tgz#0b2aa9a39f706f0bb970134047afaa326a3c923e"
integrity sha512-wSNn+TcCh+DuE2pdg058K3MhxA4g+IiZlW7yGz4cMd/t3z2rJXZcV3HDxZljbrICU2Iq0qY4UHnbolTMK/+bcA==

didyoumean@^1.2.2:
version "1.2.2"
resolved "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz#989346ffe9e839b4555ecf5666edea0d3e8ad037"
Expand Down

0 comments on commit 91448ba

Please sign in to comment.