import { Injectable } from "@nestjs/common" ; import { InjectRepository } from "@nestjs/typeorm" ; import { TypeOrmCrudService } from "@nestjsx/crud-typeorm" ; import { Repository } from "typeorm" ; import { Register , OrganizationSlug } from "../../../../shared/entities" ; import { User } from "../entities/user.entity" ; @ Injectable ( ) export class UsersService extends TypeOrmCrudService < User > { constructor ( @ InjectRepository ( User ) repo ) { super ( repo ) ; } async create ( data ) { const user = new User ( data ) ; await user . setPassword ( data . password ) ; return this . save ( user ) ; } save ( user ) { return this . repo . save ( user ) ; } async getOrgUsers ( slug ) { return this . repo . createQueryBuilder ( "user" ) . innerJoin ( "user.organizations" , "organization" , "slug = :slug" , { slug } ) . getMany ( ) ; } }