Refactor interests handling: replace 'interests' table with 'servizio_interessi' and add ServizioInteressi schema

This commit is contained in:
Marco Pedone 2025-08-05 16:21:27 +02:00
parent ce958e1bab
commit 8725055fb3
3 changed files with 12 additions and 12 deletions

View file

@ -1,6 +1,7 @@
// @generated // @generated
// This file is automatically generated by Kanel. Do not modify manually. // This file is automatically generated by Kanel. Do not modify manually.
import type { default as ServizioInteressiTable } from './ServizioInteressi';
import type { default as FlagsTable } from './Flags'; import type { default as FlagsTable } from './Flags';
import type { default as AnnunciTable } from './Annunci'; import type { default as AnnunciTable } from './Annunci';
import type { default as UsersTable } from './Users'; import type { default as UsersTable } from './Users';
@ -22,11 +23,12 @@ import type { default as StorageindexTable } from './Storageindex';
import type { default as MessagesTable } from './Messages'; import type { default as MessagesTable } from './Messages';
import type { default as UsersAnagraficaTable } from './UsersAnagrafica'; import type { default as UsersAnagraficaTable } from './UsersAnagrafica';
import type { default as BanlistTable } from './Banlist'; import type { default as BanlistTable } from './Banlist';
import type { default as InterestsTable } from './Interests';
import type { default as BannersTable } from './Banners'; import type { default as BannersTable } from './Banners';
import type { default as ServizioTable } from './Servizio'; import type { default as ServizioTable } from './Servizio';
export default interface PublicSchema { export default interface PublicSchema {
servizio_interessi: ServizioInteressiTable;
flags: FlagsTable; flags: FlagsTable;
annunci: AnnunciTable; annunci: AnnunciTable;
@ -69,8 +71,6 @@ export default interface PublicSchema {
banlist: BanlistTable; banlist: BanlistTable;
interests: InterestsTable;
banners: BannersTable; banners: BannersTable;
servizio: ServizioTable; servizio: ServizioTable;

View file

@ -5,15 +5,15 @@ import type { AnnunciId } from './Annunci';
import type { UsersId } from './Users'; import type { UsersId } from './Users';
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely'; import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
/** Represents the table public.interests */ /** Represents the table public.servizio_interessi */
export default interface InterestsTable { export default interface ServizioInteressiTable {
annuncioId: ColumnType<AnnunciId, AnnunciId, AnnunciId>; annuncioId: ColumnType<AnnunciId, AnnunciId, AnnunciId>;
userId: ColumnType<UsersId, UsersId, UsersId>; userId: ColumnType<UsersId, UsersId, UsersId>;
} }
export type Interests = Selectable<InterestsTable>; export type ServizioInteressi = Selectable<ServizioInteressiTable>;
export type NewInterests = Insertable<InterestsTable>; export type NewServizioInteressi = Insertable<ServizioInteressiTable>;
export type InterestsUpdate = Updateable<InterestsTable>; export type ServizioInteressiUpdate = Updateable<ServizioInteressiTable>;

View file

@ -12,7 +12,7 @@ export const AddIntrest = async ({
}) => { }) => {
try { try {
await db await db
.insertInto("interests") .insertInto("servizio_interessi")
.values({ .values({
annuncioId, annuncioId,
userId, userId,
@ -38,7 +38,7 @@ export const RemoveInterest = async ({
}) => { }) => {
try { try {
await db await db
.deleteFrom("interests") .deleteFrom("servizio_interessi")
.where("annuncioId", "=", annuncioId) .where("annuncioId", "=", annuncioId)
.where("userId", "=", userId) .where("userId", "=", userId)
.execute(); .execute();
@ -62,7 +62,7 @@ export const HasUserInterest = async ({
}) => { }) => {
try { try {
const interest = await db const interest = await db
.selectFrom("interests") .selectFrom("servizio_interessi")
.where("annuncioId", "=", annuncioId) .where("annuncioId", "=", annuncioId)
.where("userId", "=", userId) .where("userId", "=", userId)
.selectAll() .selectAll()
@ -82,7 +82,7 @@ export const GetUserInterests = async (userId: UsersId) => {
try { try {
return ( return (
await db await db
.selectFrom("interests") .selectFrom("servizio_interessi")
.where("userId", "=", userId) .where("userId", "=", userId)
.select("annuncioId") .select("annuncioId")
.execute() .execute()