mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor(database): 🎨 Refactor note handling into its own class instead of separate functions
This commit is contained in:
parent
2998cb4deb
commit
9081036c6d
36 changed files with 1194 additions and 1215 deletions
|
|
@ -289,7 +289,15 @@ export const user = pgTable(
|
|||
email: text("email"),
|
||||
note: text("note").default("").notNull(),
|
||||
isAdmin: boolean("is_admin").default(false).notNull(),
|
||||
endpoints: jsonb("endpoints"),
|
||||
endpoints: jsonb("endpoints").$type<Partial<{
|
||||
dislikes: string;
|
||||
featured: string;
|
||||
likes: string;
|
||||
followers: string;
|
||||
following: string;
|
||||
inbox: string;
|
||||
outbox: string;
|
||||
}> | null>(),
|
||||
source: jsonb("source").notNull(),
|
||||
avatar: text("avatar").notNull(),
|
||||
header: text("header").notNull(),
|
||||
|
|
|
|||
39
drizzle/types.ts
Normal file
39
drizzle/types.ts
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import type {
|
||||
BuildQueryResult,
|
||||
DBQueryConfig,
|
||||
ExtractTablesWithRelations,
|
||||
} from "drizzle-orm";
|
||||
|
||||
import type * as schema from "./schema";
|
||||
|
||||
type Schema = typeof schema;
|
||||
type TablesWithRelations = ExtractTablesWithRelations<Schema>;
|
||||
|
||||
export type IncludeRelation<TableName extends keyof TablesWithRelations> =
|
||||
DBQueryConfig<
|
||||
"one" | "many",
|
||||
boolean,
|
||||
TablesWithRelations,
|
||||
TablesWithRelations[TableName]
|
||||
>["with"];
|
||||
|
||||
export type IncludeColumns<TableName extends keyof TablesWithRelations> =
|
||||
DBQueryConfig<
|
||||
"one" | "many",
|
||||
boolean,
|
||||
TablesWithRelations,
|
||||
TablesWithRelations[TableName]
|
||||
>["columns"];
|
||||
|
||||
export type InferQueryModel<
|
||||
TableName extends keyof TablesWithRelations,
|
||||
Columns extends IncludeColumns<TableName> | undefined = undefined,
|
||||
With extends IncludeRelation<TableName> | undefined = undefined,
|
||||
> = BuildQueryResult<
|
||||
TablesWithRelations,
|
||||
TablesWithRelations[TableName],
|
||||
{
|
||||
columns: Columns;
|
||||
with: With;
|
||||
}
|
||||
>;
|
||||
Loading…
Add table
Add a link
Reference in a new issue