-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update-deps
- Loading branch information
Showing
8 changed files
with
80 additions
and
59 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
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 |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import { cache } from "@solidjs/router"; | ||
import { mattraxCache } from "~/cache"; | ||
import { getMattraxCache } from "~/cache"; | ||
|
||
export const cachedTenantsForOrg = cache( | ||
(orgId: string) => | ||
mattraxCache.tenants | ||
.orderBy("id") | ||
.filter((o) => o.orgId === orgId) | ||
.toArray(), | ||
getMattraxCache().then((c) => | ||
c.tenants | ||
.orderBy("id") | ||
.filter((o) => o.orgId === orgId) | ||
.toArray(), | ||
), | ||
"cachedTenantsForOrg", | ||
); |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { cache } from "@solidjs/router"; | ||
import { mattraxCache } from "~/cache"; | ||
import { getMattraxCache } from "~/cache"; | ||
|
||
// can't be in a route file that consumes it | ||
export const cachedOrgs = cache( | ||
() => mattraxCache.orgs.orderBy("id").toArray(), | ||
() => getMattraxCache().then((c) => c.orgs.orderBy("id").toArray()), | ||
"cachedOrgs", | ||
); |
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,34 @@ | ||
import Dexie from "dexie"; | ||
|
||
export type TableNames = "orgs" | "tenants"; | ||
|
||
class MattraxCache | ||
extends Dexie | ||
implements Record<TableNames, Dexie.Table<any, string>> | ||
{ | ||
orgs!: Dexie.Table<{ id: string; slug: string; name: string }, string>; | ||
tenants!: Dexie.Table< | ||
{ id: string; slug: string; name: string; orgId: string }, | ||
string | ||
>; | ||
|
||
VERSION = 1; | ||
|
||
constructor() { | ||
super("mattrax-cache"); | ||
this.version(this.VERSION).stores({ | ||
orgs: "id", | ||
tenants: "id, orgId", | ||
}); | ||
} | ||
} | ||
|
||
export type { MattraxCache }; | ||
|
||
export const mattraxCache = new MattraxCache(); | ||
|
||
export type TableData<TTable extends Dexie.Table> = TTable extends Dexie.Table< | ||
infer T | ||
> | ||
? T | ||
: never; |
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