import { Injectable } from '@nestjs/common'; import { PrismaService } from '../prisma/prisma.service'; @Injectable() export class SuggestionsService { constructor(private prisma: PrismaService) {} create(data: { name?: string; message: string }) { return this.prisma.suggestions.create({ data }); } findAll(page = 1, limit = 50) { const skip = (page - 1) * limit; return Promise.all([ this.prisma.suggestions.findMany({ skip, take: limit, orderBy: { created_at: 'desc' }, }), this.prisma.suggestions.count(), ]).then(([data, total]) => ({ data, meta: { total, page, limit, totalPages: Math.ceil(total / limit) || 1 }, })); } }