import { Injectable } from "@nestjs/common" ; import { v4 as uuidv4 } from 'uuid' ; import { UpdateUserDto } from "./dto/update-user.dto" ; import { User } from "./schemas/user.schema" ; import { UsersRepository } from "./users.repository" ; @ Injectable ( ) export class UsersService { constructor ( private readonly usersRepository ) { } async getUserById ( userId ) { return this . usersRepository . findOne ( { userId } ) ; } async getUsers ( ) { return this . usersRepository . find ( { } ) ; } async createUser ( email , age ) { return this . usersRepository . create ( { userId : uuidv4 ( ) , email , age , favoriteFoods : [ ] } ) ; } async updateUser ( userId , userUpdates ) { return this . usersRepository . findOneAndUpdate ( { userId } , userUpdates ) ; } }