import { UserEntity , UserDao } from '../database/entities/user' ; import { User } from '../../domain/users/user' ; import { UserRepository } from '../../domain/users/userRepository' ; export function createUserRepository ( ) { async function getAll ( ) { const users = await UserDao . find ( ) ; return users . map ( ( userEntity ) => userEntity . toUser ( ) ) ; } async function add ( firstName , lastName , age ) { let userModel = new UserDao ( { firstName , lastName , age } ) ; userModel = await userModel . save ( ) ; return userModel . toUser ( ) ; } return { getAll , add , } ; }