/** * The `follows` table: its row type and its guard. * * @module */ import type { SQLOutputValue } from "node:sqlite"; /** * A row of the `follows` table: one user following either another user or a * playlist. */ export interface FollowRow { /** The follow's id. */ id: string; /** The id of the user following. */ follower_id: string; /** The id of the user followed, when it is a user. */ followed_user_id: string | null; /** The id of the playlist followed, when it is a playlist. */ followed_playlist_id: string | null; /** When the follow began. */ created_at: string; /** Any other column the query selects. */ [key: string]: SQLOutputValue; } /** Checks whether `obj` is a {@link FollowRow}. */ export function isFollowRow( obj: unknown, ): obj is FollowRow { return !!obj && typeof obj === "object" && "id" in obj && typeof obj.id === "string" && "follower_id" in obj && typeof obj.follower_id === "string" && "created_at" in obj && typeof obj.created_at === "string" && "followed_user_id" in obj && (obj.followed_user_id === null || typeof obj.followed_user_id === "string") && "followed_playlist_id" in obj && (obj.followed_playlist_id === null || typeof obj.followed_playlist_id === "string"); }