import { Injectable } from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';

@Injectable()
export class ClientService {
  constructor(private prisma: PrismaService) {}

  // async getClientDocuments(userId: string) {
  //   return this.prisma.document.findMany({
  //     where: {
  //       authorId: Number(userId),
  //     },
  //   });
  // }
  async getDocuments(userId: string) {
    return this.prisma.document.findMany({
      where: {
        sharedWith: {
          some: {
            id: Number(userId),
          },
        },  
      },
      include: {
        sharedWith: {
          select: {
            id: true,
            name: true,
            email: true,
          },
        },
      },
    });
  }
}
