-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from MatheusSanchez/add-country-to-user-entity
Adding country to User
- Loading branch information
Showing
7 changed files
with
12 additions
and
30 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
prisma/migrations/20240202214129_add_country_user/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "User" ADD COLUMN "country" TEXT NOT NULL DEFAULT 'brasil'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,31 +5,8 @@ import { randomUUID } from 'crypto' | |
export class InMemoryUserRepository implements UserRepository { | ||
private db: User[] = [] | ||
|
||
|
||
// This is a way to test our controllers without necessartralyy add the | ||
// db repository; Once the program starts, one user is added to User[] and | ||
// you can get http://localhost:3333/user/9600de4f-8d18-4e69-ba7a-ed7fa210618d | ||
// to check the routes; | ||
constructor() {} | ||
|
||
// this constructor will be delete later; | ||
constructor(){ | ||
|
||
const email = '[email protected]' | ||
const name = 'John' | ||
const surname = 'Doe' | ||
const password_hash = 'password_hash' | ||
const id = '9600de4f-8d18-4e69-ba7a-ed7fa210618d' | ||
|
||
this.create({ | ||
id, | ||
name, | ||
surname, | ||
email, | ||
password_hash, | ||
}) | ||
|
||
} | ||
|
||
async findByEmail(email: string): Promise<User | null> { | ||
const User = this.db.find((User) => User.email === email) | ||
|
||
|
@@ -58,9 +35,10 @@ export class InMemoryUserRepository implements UserRepository { | |
surname, | ||
email, | ||
password_hash, | ||
country, | ||
}: Prisma.UserCreateInput) { | ||
const user: User = { | ||
id: (id == undefined) ? randomUUID() : id, | ||
id: id == undefined ? randomUUID() : id, | ||
name, | ||
surname, | ||
|
||
|
@@ -69,11 +47,10 @@ export class InMemoryUserRepository implements UserRepository { | |
|
||
created_at: new Date(), | ||
updated_at: new Date(), | ||
country: country || 'brasil', | ||
} | ||
|
||
this.db.push(user) | ||
|
||
return user | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters