grill-blog/database.ts
2024-05-13 23:50:54 +02:00

23 lines
680 B
TypeScript

import { Option, Result } from "./utils.ts";
export type User = {
id: number;
username: string;
passwordHash: string;
};
export type Session = {
id: number;
userId: number;
};
export interface Database {
createUser(init: Omit<User, "id">): Promise<Result<User, string>>;
userWithId(id: number): Promise<Result<Option<User>, string>>;
userWithUsername(username: string): Promise<Result<Option<User>, string>>;
userWithUsernameExists(username: string): Promise<Result<boolean, string>>;
createSession(init: Omit<Session, "id">): Promise<Result<Session, string>>;
sessionWithId(id: number): Promise<Result<Option<Session>, string>>;
}