Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/prisma user model #42

Merged
merged 4 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ datasource db {
}
```

7. Once you are ready to push your schema to PlanetScale, run `prisma db push`` against your PlanetScale database to update the schema in your database.
7. Once you are ready to push your schema to PlanetScale, run `prisma db push` against your PlanetScale database to update the schema in your database.

```bash
npx prisma db push
Expand Down
3 changes: 0 additions & 3 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
"type": "module",
"scripts": {
"build": "npx tsc",
"prestart": "npx prisma migrate deploy && npx prisma generate",
"start": "node dist/src/index.js",
"predev": "npx prisma migrate dev --name init && npx prisma generate",
"dev": "nodemon -e ts --exec \"npm run build && node dist/src/index.js\"",
"pretest": "npx prisma migrate dev --name init && npx prisma generate",
"test": "npm run build && mocha \"dist/test/**/*.test.js\""
},
"keywords": [],
Expand Down
51 changes: 33 additions & 18 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,43 @@ generator client {
}

datasource db {
provider = "mysql"
url = env("DATABASE_URL")
provider = "mysql"
url = env("DATABASE_URL")
relationMode = "prisma"
}

model Product {
id Int @id @default(uuid())
title String @unique
size String
color String
description String
gender String
category String
price Float
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
id String @id @default(uuid())
title String @unique
size String
color String
description String
gender String
category String
price Float
imageUrl String @map("image_url")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
}

model Purchase_history {
id Int @id @default(uuid())
email String @unique
productId Int
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
model Order {
id String @id @default(uuid())
email String
productId Int @map("product_id")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
}

model User {
id String @id @default(uuid())
phoneNumber String @unique @map("phone_number")
email String @unique
password String
firstName String @map("first_name")
lastName String @map("last_name")
gender String
postalCode String @map("postal_code")
dateOfBirth DateTime @map("date_of_birth")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
}
50 changes: 0 additions & 50 deletions backend/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,53 +26,3 @@ export interface AlgorithmControllerInterface {
export interface AlgorithmServiceInterface {
isClothingEcoFriendly(prompt: string): Promise<boolean>;
}

export interface AuthenticationControllerInterface {
postLogin: (
req: Request,
res: Response,
next: NextFunction
) => Promise<void | Response<any, Record<string, any>>>;
postSignup: (
req: Request,
res: Response,
next: NextFunction
) => Promise<void | Response<any, Record<string, any>>>;
postLogout: (
req: Request,
res: Response,
next: NextFunction
) => Promise<void | Response<any, Record<string, any>>>;
}

export interface AuthenticationServiceInterface {
login(): Promise<void>;
signup(): Promise<void>;
logout(): Promise<void>;
}

export interface UserRepositoryInterface {
createUser(user: UserInterface): Promise<PrismaUserInterface>;
getUserByEmail(email: string): Promise<PrismaUserInterface | null>;
}

export interface UserInterface {
getEmail(): string;
getPassword(): string;
getFirstName(): string;
getLastName(): string;
setEmail(email: string): void;
setPassword(password: string): void;
setFirstName(firstName: string): void;
setLastName(lastName: string): void;
}

export interface PrismaUserInterface {
id: string;
email: string;
password: string;
firstName: string;
lastName: string;
createdAt: Date;
updatedAt: Date;
}
6 changes: 0 additions & 6 deletions package-lock.json

This file was deleted.