chore: add typeorm config
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity()
|
||||
export class User {
|
||||
@PrimaryGeneratedColumn("uuid")
|
||||
id: string;
|
||||
|
||||
@Column({ type: "varchar", length: 150, unique: true })
|
||||
email: string;
|
||||
|
||||
@Column({ type: "varchar", length: 11, unique: true })
|
||||
phoneNumber: string;
|
||||
|
||||
@Column({ type: "varchar", length: 150 })
|
||||
password: string;
|
||||
|
||||
@Column({ type: "varchar", length: 150 })
|
||||
fistName: string;
|
||||
|
||||
@Column({ type: "varchar", length: 200 })
|
||||
lastName: string;
|
||||
|
||||
@Column()
|
||||
birthDate: string;
|
||||
|
||||
@Column({ type: "varchar", length: 100 })
|
||||
nationalCode: string;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { InjectRepository } from "@nestjs/typeorm";
|
||||
import { Repository } from "typeorm";
|
||||
|
||||
import { User } from "../entities/user.entity";
|
||||
|
||||
@Injectable()
|
||||
export class UserRepository extends Repository<User> {
|
||||
constructor(@InjectRepository(User) private userRepository: Repository<User>) {
|
||||
super(userRepository.target, userRepository.manager, userRepository.queryRunner);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
|
||||
@Injectable()
|
||||
export class UsersService {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { Controller } from "@nestjs/common";
|
||||
|
||||
@Controller("users")
|
||||
export class UsersController {}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { Module } from "@nestjs/common";
|
||||
import { TypeOrmModule } from "@nestjs/typeorm";
|
||||
|
||||
import { User } from "./entities/user.entity";
|
||||
import { UserRepository } from "./providers/users.repository";
|
||||
import { UsersService } from "./providers/users.service";
|
||||
import { UsersController } from "./users.controller";
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([User])],
|
||||
providers: [UsersService, UserRepository],
|
||||
controllers: [UsersController],
|
||||
exports: [UsersService, TypeOrmModule],
|
||||
})
|
||||
export class UsersModule {}
|
||||
Reference in New Issue
Block a user