diff --git a/prisma/migrations/20200629222336/README.md b/prisma/migrations/20200629222336/README.md deleted file mode 100644 index 20e6762..0000000 --- a/prisma/migrations/20200629222336/README.md +++ /dev/null @@ -1,264 +0,0 @@ -# Migration `20200629222336` - -This migration has been generated by boorim98 at 6/29/2020, 10:23:36 PM. -You can check out the [state of the schema](./schema.prisma) after the migration. - -## Database Steps - -```sql -CREATE TABLE `petmily`.`hotel` ( -`address` varchar(191) ,`address_detail` varchar(191) ,`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ,`description` varchar(191) ,`id` int NOT NULL AUTO_INCREMENT,`is_neutered_only` boolean ,`largs_criteria` int ,`latitude` Decimal(65,30) ,`longitude` Decimal(65,30) ,`max_dog_size` int ,`medium_criteria` int ,`monitor_available` boolean ,`name` varchar(191) ,`page_link` varchar(191) ,`phone_number` varchar(191) ,`sat_close_time` varchar(191) ,`sat_open_time` varchar(191) ,`sun_close_time` varchar(191) ,`sun_open_time` varchar(191) ,`updated_at` datetime(3) ,`week_close_time` varchar(191) ,`week_open_time` varchar(191) ,`zipcode` varchar(191) , - PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci - -CREATE TABLE `petmily`.`hotel_monitoring_type` ( -`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ,`hotel_id` int NOT NULL ,`id` int NOT NULL AUTO_INCREMENT,`name` varchar(191) ,`updated_at` datetime(3) , - PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci - -CREATE TABLE `petmily`.`hotel_service` ( -`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ,`hotel_id` int NOT NULL ,`id` int NOT NULL AUTO_INCREMENT,`name` varchar(191) ,`updated_at` datetime(3) , - PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci - -CREATE TABLE `petmily`.`price` ( -`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ,`day` varchar(191) ,`hotel_id` int NOT NULL ,`id` int NOT NULL AUTO_INCREMENT,`price` int ,`size` ENUM('small', 'medium', 'large') ,`updated_at` datetime(3) ,`weight` int , - PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci - -CREATE TABLE `petmily`.`photo` ( -`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ,`id` int NOT NULL AUTO_INCREMENT,`target` ENUM('pet', 'user', 'hotel') ,`target_id` int ,`updated_at` datetime(3) ,`url` varchar(191) , - PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci - -CREATE TABLE `petmily`.`user` ( -`access_token` varchar(191) ,`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ,`email` varchar(191) NOT NULL ,`id` int NOT NULL AUTO_INCREMENT,`name` varchar(191) ,`password` varchar(191) ,`phone_number` varchar(191) ,`provider` ENUM('kakao', 'naver', 'google', 'facebook') ,`refresh_token` varchar(191) ,`updated_at` datetime(3) , - PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci - -CREATE TABLE `petmily`.`pet` ( -`breed` varchar(191) ,`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ,`gender` ENUM('수컷', '암컷') ,`id` int NOT NULL AUTO_INCREMENT,`is_neutered` boolean ,`name` varchar(191) ,`register_num` varchar(191) ,`rfid_cd` varchar(191) ,`updated_at` datetime(3) ,`user_id` int ,`weight` int ,`year` int , - PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci - -CREATE TABLE `petmily`.`reservation` ( -`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ,`end_date` datetime(3) ,`hotel_id` int NOT NULL ,`id` int NOT NULL AUTO_INCREMENT,`pet_id` int NOT NULL ,`pick_up_time` varchar(191) ,`request` varchar(191) ,`start_date` datetime(3) ,`updated_at` datetime(3) ,`user_id` int NOT NULL , - PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci - -CREATE TABLE `petmily`.`_HotelToUser` ( -`A` int NOT NULL ,`B` int NOT NULL -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci - -CREATE UNIQUE INDEX `user.name` ON `petmily`.`user`(`name`) - -CREATE UNIQUE INDEX `user.email` ON `petmily`.`user`(`email`) - -CREATE UNIQUE INDEX `_HotelToUser_AB_unique` ON `petmily`.`_HotelToUser`(`A`,`B`) - -CREATE INDEX `_HotelToUser_B_index` ON `petmily`.`_HotelToUser`(`B`) - -ALTER TABLE `petmily`.`hotel_monitoring_type` ADD FOREIGN KEY (`hotel_id`) REFERENCES `petmily`.`hotel`(`id`) ON DELETE CASCADE ON UPDATE CASCADE - -ALTER TABLE `petmily`.`hotel_service` ADD FOREIGN KEY (`hotel_id`) REFERENCES `petmily`.`hotel`(`id`) ON DELETE CASCADE ON UPDATE CASCADE - -ALTER TABLE `petmily`.`price` ADD FOREIGN KEY (`hotel_id`) REFERENCES `petmily`.`hotel`(`id`) ON DELETE CASCADE ON UPDATE CASCADE - -ALTER TABLE `petmily`.`pet` ADD FOREIGN KEY (`user_id`) REFERENCES `petmily`.`user`(`id`) ON DELETE SET NULL ON UPDATE CASCADE - -ALTER TABLE `petmily`.`reservation` ADD FOREIGN KEY (`user_id`) REFERENCES `petmily`.`user`(`id`) ON DELETE CASCADE ON UPDATE CASCADE - -ALTER TABLE `petmily`.`reservation` ADD FOREIGN KEY (`hotel_id`) REFERENCES `petmily`.`hotel`(`id`) ON DELETE CASCADE ON UPDATE CASCADE - -ALTER TABLE `petmily`.`reservation` ADD FOREIGN KEY (`pet_id`) REFERENCES `petmily`.`pet`(`id`) ON DELETE CASCADE ON UPDATE CASCADE - -ALTER TABLE `petmily`.`_HotelToUser` ADD FOREIGN KEY (`A`) REFERENCES `petmily`.`hotel`(`id`) ON DELETE CASCADE ON UPDATE CASCADE - -ALTER TABLE `petmily`.`_HotelToUser` ADD FOREIGN KEY (`B`) REFERENCES `petmily`.`user`(`id`) ON DELETE CASCADE ON UPDATE CASCADE -``` - -## Changes - -```diff -diff --git schema.prisma schema.prisma -migration ..20200629222336 ---- datamodel.dml -+++ datamodel.dml -@@ -1,0 +1,176 @@ -+datasource mysql { -+ url = env("DATABASE_URL") -+ provider = "mysql" -+} -+ -+generator client { -+ provider = "prisma-client-js" -+} -+ -+model Hotel { -+ id Int @default(autoincrement()) @id -+ createdAt DateTime @default(now()) @map("created_at") -+ updatedAt DateTime? @map("updated_at") @updatedAt -+ name String? -+ description String? -+ address String? -+ addressDetail String? @map("address_detail") -+ zipcode String? -+ latitude Float? -+ longitude Float? -+ weekOpenTime String? @map("week_open_time") -+ weekCloseTime String? @map("week_close_time") -+ satOpenTime String? @map("sat_open_time") -+ satCloseTime String? @map("sat_close_time") -+ sunOpenTime String? @map("sun_open_time") -+ sunCloseTime String? @map("sun_close_time") -+ phoneNumber String? @map("phone_number") -+ monitorAvailable Boolean? @map("monitor_available") -+ isNeuteredOnly Boolean? @map("is_neutered_only") -+ maxDogSize Int? @map("max_dog_size") -+ pageLink String? @map("page_link") -+ mediumCriteria Int? @map("medium_criteria") //소형견과 중형견을 나누는 기준 -+ largeCriteria Int? @map("largs_criteria") //중형견과 대형견을 나누는 기준 -+ monitorings Monitoring[] -+ services Service[] -+ prices Price[] -+ reservations Reservation[] -+ customers User[] @relation(references: [id]) -+ -+ @@map("hotel") -+} -+ -+model Monitoring { -+ id Int @default(autoincrement()) @id -+ hotelId Int @map("hotel_id") -+ createdAt DateTime @default(now()) @map("created_at") -+ updatedAt DateTime? @map("updated_at") @updatedAt -+ name String? -+ hotel Hotel @relation(fields: [hotelId], references: [id]) -+ -+ @@map("hotel_monitoring_type") -+} -+ -+model Service { -+ id Int @default(autoincrement()) @id -+ hotelId Int @map("hotel_id") -+ createdAt DateTime @default(now()) @map("created_at") -+ updatedAt DateTime? @map("updated_at") @updatedAt -+ name String? -+ hotel Hotel @relation(fields: [hotelId], references: [id]) -+ -+ @@map("hotel_service") -+} -+ -+model Price { -+ id Int @default(autoincrement()) @id -+ hotelId Int @map("hotel_id") -+ createdAt DateTime @default(now()) @map("created_at") -+ updatedAt DateTime? @map("updated_at") @updatedAt -+ day String? -+ weight Int? -+ size Size? -+ price Int? -+ hotel Hotel @relation(fields: [hotelId], references: [id]) -+ -+ @@map("price") -+} -+ -+model Photo { -+ id Int @default(autoincrement()) @id -+ createdAt DateTime @default(now()) @map("created_at") -+ updatedAt DateTime? @map("updated_at") @updatedAt -+ url String? -+ target Target? -+ targetId Int? @map("target_id") -+ -+ @@map("photo") -+} -+ -+model User { -+ id Int @default(autoincrement()) @id -+ createdAt DateTime @default(now()) @map("created_at") -+ updatedAt DateTime? @map("updated_at") @updatedAt -+ name String? @unique -+ email String @unique -+ password String? -+ provider Provider? -+ accessToken String? @map("access_token") -+ refreshToken String? @map("refresh_token") -+ phoneNumber String? @map("phone_number") -+ pets Pet[] -+ favoriteHotels Hotel[] @relation(references: [id]) -+ Reservation Reservation[] -+ -+ @@map("user") -+ -+} -+ -+model Pet { -+ id Int @default(autoincrement()) @id -+ userId Int? @map("user_id") -+ createdAt DateTime @default(now()) @map("created_at") -+ updatedAt DateTime? @map("updated_at") @updatedAt -+ name String? -+ year Int? -+ weight Int? -+ registerNum String? @map("register_num") -+ rfidCode String? @map("rfid_cd") -+ breed String? -+ isNeutered Boolean? @map("is_neutered") -+ gender Gender? -+ owner User? @relation(fields: [userId], references: [id]) -+ reservations Reservation[] -+ -+ @@map("pet") -+} -+ -+model Reservation { -+ id Int @default(autoincrement()) @id -+ userId Int @map("user_id") -+ hotelId Int @map("hotel_id") -+ petId Int @map("pet_id") -+ createdAt DateTime @default(now()) @map("created_at") -+ updatedAt DateTime? @map("updated_at") @updatedAt -+ startDate DateTime? @map("start_date") -+ endDate DateTime? @map("end_date") -+ pickupTime String? @map("pick_up_time") -+ request String? -+ user User @relation(fields: [userId], references: [id]) -+ hotel Hotel @relation(fields: [hotelId], references: [id]) -+ pet Pet @relation(fields: [petId], references: [id]) -+ -+ @@map("reservation") -+} -+ -+enum Gender { -+ MALE @map("수컷") -+ FEMAIL @map("암컷") -+ -+ @@map("gender") -+} -+ -+enum Target { -+ PET @map("pet") -+ USER @map("user") -+ HOTEL @map("hotel") -+ -+ @@map("target") -+} -+ -+enum Size { -+ SMALL @map("small") -+ MEDIUM @map("medium") -+ LARGE @map("large") -+ -+ @@map("size") -+} -+ -+enum Provider { -+ KAKAO @map("kakao") -+ NAVER @map("naver") -+ GOOGLE @map("google") -+ FACEBOOK @map("facebook") -+ -+ @@map("provider") -+} -``` diff --git a/prisma/migrations/20200629222336/schema.prisma b/prisma/migrations/20200629222336/schema.prisma deleted file mode 100644 index 5eaf019..0000000 --- a/prisma/migrations/20200629222336/schema.prisma +++ /dev/null @@ -1,163 +0,0 @@ -datasource mysql { - url = "***" - provider = "mysql" -} - -generator client { - provider = "prisma-client-js" -} - -model Hotel { - id Int @default(autoincrement()) @id - createdAt DateTime @default(now()) @map("created_at") - updatedAt DateTime? @map("updated_at") @updatedAt - name String? - description String? - address String? - addressDetail String? @map("address_detail") - zipcode String? - latitude Float? - longitude Float? - weekOpenTime String? @map("week_open_time") - weekCloseTime String? @map("week_close_time") - satOpenTime String? @map("sat_open_time") - satCloseTime String? @map("sat_close_time") - sunOpenTime String? @map("sun_open_time") - sunCloseTime String? @map("sun_close_time") - phoneNumber String? @map("phone_number") - monitorAvailable Boolean? @map("monitor_available") - isNeuteredOnly Boolean? @map("is_neutered_only") - maxDogSize Int? @map("max_dog_size") - pageLink String? @map("page_link") - mediumCriteria Int? @map("medium_criteria") //소형견과 중형견을 나누는 기준 - largeCriteria Int? @map("largs_criteria") //중형견과 대형견을 나누는 기준 - monitorings Monitoring[] - services Service[] - prices Price[] - reservations Reservation[] - customers User[] @relation(references: [id]) - @@map("hotel") -} - -model Monitoring { - id Int @default(autoincrement()) @id - hotelId Int @map("hotel_id") - createdAt DateTime @default(now()) @map("created_at") - updatedAt DateTime? @map("updated_at") @updatedAt - name String? - hotel Hotel @relation(fields: [hotelId], references: [id]) - @@map("hotel_monitoring_type") -} - -model Service { - id Int @default(autoincrement()) @id - hotelId Int @map("hotel_id") - createdAt DateTime @default(now()) @map("created_at") - updatedAt DateTime? @map("updated_at") @updatedAt - name String? - hotel Hotel @relation(fields: [hotelId], references: [id]) - @@map("hotel_service") -} - -model Price { - id Int @default(autoincrement()) @id - hotelId Int @map("hotel_id") - createdAt DateTime @default(now()) @map("created_at") - updatedAt DateTime? @map("updated_at") @updatedAt - day String? - weight Int? - size Size? - price Int? - hotel Hotel @relation(fields: [hotelId], references: [id]) - @@map("price") -} - -model Photo { - id Int @default(autoincrement()) @id - createdAt DateTime @default(now()) @map("created_at") - updatedAt DateTime? @map("updated_at") @updatedAt - url String? - target Target? - targetId Int? @map("target_id") - @@map("photo") -} - -model User { - id Int @default(autoincrement()) @id - createdAt DateTime @default(now()) @map("created_at") - updatedAt DateTime? @map("updated_at") @updatedAt - name String? @unique - email String @unique - password String? - provider Provider? - accessToken String? @map("access_token") - refreshToken String? @map("refresh_token") - phoneNumber String? @map("phone_number") - pets Pet[] - favoriteHotels Hotel[] @relation(references: [id]) - Reservation Reservation[] - @@map("user") -} - -model Pet { - id Int @default(autoincrement()) @id - userId Int? @map("user_id") - createdAt DateTime @default(now()) @map("created_at") - updatedAt DateTime? @map("updated_at") @updatedAt - name String? - year Int? - weight Int? - registerNum String? @map("register_num") - rfidCode String? @map("rfid_cd") - breed String? - isNeutered Boolean? @map("is_neutered") - gender Gender? - owner User? @relation(fields: [userId], references: [id]) - reservations Reservation[] - @@map("pet") -} - -model Reservation { - id Int @default(autoincrement()) @id - userId Int @map("user_id") - hotelId Int @map("hotel_id") - petId Int @map("pet_id") - createdAt DateTime @default(now()) @map("created_at") - updatedAt DateTime? @map("updated_at") @updatedAt - startDate DateTime? @map("start_date") - endDate DateTime? @map("end_date") - pickupTime String? @map("pick_up_time") - request String? - user User @relation(fields: [userId], references: [id]) - hotel Hotel @relation(fields: [hotelId], references: [id]) - pet Pet @relation(fields: [petId], references: [id]) - @@map("reservation") -} - -enum Gender { - MALE @map("수컷") - FEMAIL @map("암컷") - @@map("gender") -} - -enum Target { - PET @map("pet") - USER @map("user") - HOTEL @map("hotel") - @@map("target") -} - -enum Size { - SMALL @map("small") - MEDIUM @map("medium") - LARGE @map("large") - @@map("size") -} - -enum Provider { - KAKAO @map("kakao") - NAVER @map("naver") - GOOGLE @map("google") - FACEBOOK @map("facebook") - @@map("provider") -} diff --git a/prisma/migrations/20200629222336/steps.json b/prisma/migrations/20200629222336/steps.json deleted file mode 100644 index ba702a5..0000000 --- a/prisma/migrations/20200629222336/steps.json +++ /dev/null @@ -1,3416 +0,0 @@ -{ - "version": "0.3.14-fixed", - "steps": [ - { - "tag": "CreateEnum", - "enum": "Gender", - "values": ["MALE", "FEMAIL"] - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Enum", - "enum": "Gender" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Enum", - "enum": "Gender" - }, - "directive": "map" - }, - "argument": "", - "value": "\"gender\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "EnumValue", - "enum": "Gender", - "value": "MALE" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "EnumValue", - "enum": "Gender", - "value": "MALE" - }, - "directive": "map" - }, - "argument": "", - "value": "\"수컷\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "EnumValue", - "enum": "Gender", - "value": "FEMAIL" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "EnumValue", - "enum": "Gender", - "value": "FEMAIL" - }, - "directive": "map" - }, - "argument": "", - "value": "\"암컷\"" - }, - { - "tag": "CreateEnum", - "enum": "Target", - "values": ["PET", "USER", "HOTEL"] - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Enum", - "enum": "Target" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Enum", - "enum": "Target" - }, - "directive": "map" - }, - "argument": "", - "value": "\"target\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "EnumValue", - "enum": "Target", - "value": "PET" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "EnumValue", - "enum": "Target", - "value": "PET" - }, - "directive": "map" - }, - "argument": "", - "value": "\"pet\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "EnumValue", - "enum": "Target", - "value": "USER" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "EnumValue", - "enum": "Target", - "value": "USER" - }, - "directive": "map" - }, - "argument": "", - "value": "\"user\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "EnumValue", - "enum": "Target", - "value": "HOTEL" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "EnumValue", - "enum": "Target", - "value": "HOTEL" - }, - "directive": "map" - }, - "argument": "", - "value": "\"hotel\"" - }, - { - "tag": "CreateEnum", - "enum": "Size", - "values": ["SMALL", "MEDIUM", "LARGE"] - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Enum", - "enum": "Size" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Enum", - "enum": "Size" - }, - "directive": "map" - }, - "argument": "", - "value": "\"size\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "EnumValue", - "enum": "Size", - "value": "SMALL" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "EnumValue", - "enum": "Size", - "value": "SMALL" - }, - "directive": "map" - }, - "argument": "", - "value": "\"small\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "EnumValue", - "enum": "Size", - "value": "MEDIUM" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "EnumValue", - "enum": "Size", - "value": "MEDIUM" - }, - "directive": "map" - }, - "argument": "", - "value": "\"medium\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "EnumValue", - "enum": "Size", - "value": "LARGE" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "EnumValue", - "enum": "Size", - "value": "LARGE" - }, - "directive": "map" - }, - "argument": "", - "value": "\"large\"" - }, - { - "tag": "CreateEnum", - "enum": "Provider", - "values": ["KAKAO", "NAVER", "GOOGLE", "FACEBOOK"] - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Enum", - "enum": "Provider" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Enum", - "enum": "Provider" - }, - "directive": "map" - }, - "argument": "", - "value": "\"provider\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "EnumValue", - "enum": "Provider", - "value": "KAKAO" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "EnumValue", - "enum": "Provider", - "value": "KAKAO" - }, - "directive": "map" - }, - "argument": "", - "value": "\"kakao\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "EnumValue", - "enum": "Provider", - "value": "NAVER" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "EnumValue", - "enum": "Provider", - "value": "NAVER" - }, - "directive": "map" - }, - "argument": "", - "value": "\"naver\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "EnumValue", - "enum": "Provider", - "value": "GOOGLE" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "EnumValue", - "enum": "Provider", - "value": "GOOGLE" - }, - "directive": "map" - }, - "argument": "", - "value": "\"google\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "EnumValue", - "enum": "Provider", - "value": "FACEBOOK" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "EnumValue", - "enum": "Provider", - "value": "FACEBOOK" - }, - "directive": "map" - }, - "argument": "", - "value": "\"facebook\"" - }, - { - "tag": "CreateSource", - "source": "mysql" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Source", - "source": "mysql" - }, - "argument": "url", - "value": "env(\"DATABASE_URL\")" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Source", - "source": "mysql" - }, - "argument": "provider", - "value": "\"mysql\"" - }, - { - "tag": "CreateModel", - "model": "Hotel" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "id", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Hotel", - "field": "id" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Hotel", - "field": "id" - }, - "directive": "default" - }, - "argument": "", - "value": "autoincrement()" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Hotel", - "field": "id" - }, - "directive": "id" - } - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "createdAt", - "type": "DateTime", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Hotel", - "field": "createdAt" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Hotel", - "field": "createdAt" - }, - "directive": "default" - }, - "argument": "", - "value": "now()" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Hotel", - "field": "createdAt" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Hotel", - "field": "createdAt" - }, - "directive": "map" - }, - "argument": "", - "value": "\"created_at\"" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "updatedAt", - "type": "DateTime", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Hotel", - "field": "updatedAt" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Hotel", - "field": "updatedAt" - }, - "directive": "map" - }, - "argument": "", - "value": "\"updated_at\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Hotel", - "field": "updatedAt" - }, - "directive": "updatedAt" - } - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "name", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "description", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "address", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "addressDetail", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Hotel", - "field": "addressDetail" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Hotel", - "field": "addressDetail" - }, - "directive": "map" - }, - "argument": "", - "value": "\"address_detail\"" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "zipcode", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "latitude", - "type": "Float", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "longitude", - "type": "Float", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "weekOpenTime", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Hotel", - "field": "weekOpenTime" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Hotel", - "field": "weekOpenTime" - }, - "directive": "map" - }, - "argument": "", - "value": "\"week_open_time\"" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "weekCloseTime", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Hotel", - "field": "weekCloseTime" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Hotel", - "field": "weekCloseTime" - }, - "directive": "map" - }, - "argument": "", - "value": "\"week_close_time\"" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "satOpenTime", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Hotel", - "field": "satOpenTime" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Hotel", - "field": "satOpenTime" - }, - "directive": "map" - }, - "argument": "", - "value": "\"sat_open_time\"" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "satCloseTime", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Hotel", - "field": "satCloseTime" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Hotel", - "field": "satCloseTime" - }, - "directive": "map" - }, - "argument": "", - "value": "\"sat_close_time\"" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "sunOpenTime", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Hotel", - "field": "sunOpenTime" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Hotel", - "field": "sunOpenTime" - }, - "directive": "map" - }, - "argument": "", - "value": "\"sun_open_time\"" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "sunCloseTime", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Hotel", - "field": "sunCloseTime" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Hotel", - "field": "sunCloseTime" - }, - "directive": "map" - }, - "argument": "", - "value": "\"sun_close_time\"" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "phoneNumber", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Hotel", - "field": "phoneNumber" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Hotel", - "field": "phoneNumber" - }, - "directive": "map" - }, - "argument": "", - "value": "\"phone_number\"" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "monitorAvailable", - "type": "Boolean", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Hotel", - "field": "monitorAvailable" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Hotel", - "field": "monitorAvailable" - }, - "directive": "map" - }, - "argument": "", - "value": "\"monitor_available\"" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "isNeuteredOnly", - "type": "Boolean", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Hotel", - "field": "isNeuteredOnly" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Hotel", - "field": "isNeuteredOnly" - }, - "directive": "map" - }, - "argument": "", - "value": "\"is_neutered_only\"" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "maxDogSize", - "type": "Int", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Hotel", - "field": "maxDogSize" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Hotel", - "field": "maxDogSize" - }, - "directive": "map" - }, - "argument": "", - "value": "\"max_dog_size\"" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "pageLink", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Hotel", - "field": "pageLink" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Hotel", - "field": "pageLink" - }, - "directive": "map" - }, - "argument": "", - "value": "\"page_link\"" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "mediumCriteria", - "type": "Int", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Hotel", - "field": "mediumCriteria" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Hotel", - "field": "mediumCriteria" - }, - "directive": "map" - }, - "argument": "", - "value": "\"medium_criteria\"" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "largeCriteria", - "type": "Int", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Hotel", - "field": "largeCriteria" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Hotel", - "field": "largeCriteria" - }, - "directive": "map" - }, - "argument": "", - "value": "\"largs_criteria\"" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "monitorings", - "type": "Monitoring", - "arity": "List" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "services", - "type": "Service", - "arity": "List" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "prices", - "type": "Price", - "arity": "List" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "reservations", - "type": "Reservation", - "arity": "List" - }, - { - "tag": "CreateField", - "model": "Hotel", - "field": "customers", - "type": "User", - "arity": "List" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Hotel", - "field": "customers" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Hotel", - "field": "customers" - }, - "directive": "relation" - }, - "argument": "references", - "value": "[id]" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Model", - "model": "Hotel" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Model", - "model": "Hotel" - }, - "directive": "map" - }, - "argument": "", - "value": "\"hotel\"" - }, - { - "tag": "CreateModel", - "model": "Monitoring" - }, - { - "tag": "CreateField", - "model": "Monitoring", - "field": "id", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Monitoring", - "field": "id" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Monitoring", - "field": "id" - }, - "directive": "default" - }, - "argument": "", - "value": "autoincrement()" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Monitoring", - "field": "id" - }, - "directive": "id" - } - }, - { - "tag": "CreateField", - "model": "Monitoring", - "field": "hotelId", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Monitoring", - "field": "hotelId" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Monitoring", - "field": "hotelId" - }, - "directive": "map" - }, - "argument": "", - "value": "\"hotel_id\"" - }, - { - "tag": "CreateField", - "model": "Monitoring", - "field": "createdAt", - "type": "DateTime", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Monitoring", - "field": "createdAt" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Monitoring", - "field": "createdAt" - }, - "directive": "default" - }, - "argument": "", - "value": "now()" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Monitoring", - "field": "createdAt" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Monitoring", - "field": "createdAt" - }, - "directive": "map" - }, - "argument": "", - "value": "\"created_at\"" - }, - { - "tag": "CreateField", - "model": "Monitoring", - "field": "updatedAt", - "type": "DateTime", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Monitoring", - "field": "updatedAt" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Monitoring", - "field": "updatedAt" - }, - "directive": "map" - }, - "argument": "", - "value": "\"updated_at\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Monitoring", - "field": "updatedAt" - }, - "directive": "updatedAt" - } - }, - { - "tag": "CreateField", - "model": "Monitoring", - "field": "name", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Monitoring", - "field": "hotel", - "type": "Hotel", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Monitoring", - "field": "hotel" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Monitoring", - "field": "hotel" - }, - "directive": "relation" - }, - "argument": "fields", - "value": "[hotelId]" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Monitoring", - "field": "hotel" - }, - "directive": "relation" - }, - "argument": "references", - "value": "[id]" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Model", - "model": "Monitoring" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Model", - "model": "Monitoring" - }, - "directive": "map" - }, - "argument": "", - "value": "\"hotel_monitoring_type\"" - }, - { - "tag": "CreateModel", - "model": "Service" - }, - { - "tag": "CreateField", - "model": "Service", - "field": "id", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Service", - "field": "id" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Service", - "field": "id" - }, - "directive": "default" - }, - "argument": "", - "value": "autoincrement()" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Service", - "field": "id" - }, - "directive": "id" - } - }, - { - "tag": "CreateField", - "model": "Service", - "field": "hotelId", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Service", - "field": "hotelId" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Service", - "field": "hotelId" - }, - "directive": "map" - }, - "argument": "", - "value": "\"hotel_id\"" - }, - { - "tag": "CreateField", - "model": "Service", - "field": "createdAt", - "type": "DateTime", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Service", - "field": "createdAt" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Service", - "field": "createdAt" - }, - "directive": "default" - }, - "argument": "", - "value": "now()" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Service", - "field": "createdAt" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Service", - "field": "createdAt" - }, - "directive": "map" - }, - "argument": "", - "value": "\"created_at\"" - }, - { - "tag": "CreateField", - "model": "Service", - "field": "updatedAt", - "type": "DateTime", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Service", - "field": "updatedAt" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Service", - "field": "updatedAt" - }, - "directive": "map" - }, - "argument": "", - "value": "\"updated_at\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Service", - "field": "updatedAt" - }, - "directive": "updatedAt" - } - }, - { - "tag": "CreateField", - "model": "Service", - "field": "name", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Service", - "field": "hotel", - "type": "Hotel", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Service", - "field": "hotel" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Service", - "field": "hotel" - }, - "directive": "relation" - }, - "argument": "fields", - "value": "[hotelId]" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Service", - "field": "hotel" - }, - "directive": "relation" - }, - "argument": "references", - "value": "[id]" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Model", - "model": "Service" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Model", - "model": "Service" - }, - "directive": "map" - }, - "argument": "", - "value": "\"hotel_service\"" - }, - { - "tag": "CreateModel", - "model": "Price" - }, - { - "tag": "CreateField", - "model": "Price", - "field": "id", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Price", - "field": "id" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Price", - "field": "id" - }, - "directive": "default" - }, - "argument": "", - "value": "autoincrement()" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Price", - "field": "id" - }, - "directive": "id" - } - }, - { - "tag": "CreateField", - "model": "Price", - "field": "hotelId", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Price", - "field": "hotelId" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Price", - "field": "hotelId" - }, - "directive": "map" - }, - "argument": "", - "value": "\"hotel_id\"" - }, - { - "tag": "CreateField", - "model": "Price", - "field": "createdAt", - "type": "DateTime", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Price", - "field": "createdAt" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Price", - "field": "createdAt" - }, - "directive": "default" - }, - "argument": "", - "value": "now()" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Price", - "field": "createdAt" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Price", - "field": "createdAt" - }, - "directive": "map" - }, - "argument": "", - "value": "\"created_at\"" - }, - { - "tag": "CreateField", - "model": "Price", - "field": "updatedAt", - "type": "DateTime", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Price", - "field": "updatedAt" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Price", - "field": "updatedAt" - }, - "directive": "map" - }, - "argument": "", - "value": "\"updated_at\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Price", - "field": "updatedAt" - }, - "directive": "updatedAt" - } - }, - { - "tag": "CreateField", - "model": "Price", - "field": "day", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Price", - "field": "weight", - "type": "Int", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Price", - "field": "size", - "type": "Size", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Price", - "field": "price", - "type": "Int", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Price", - "field": "hotel", - "type": "Hotel", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Price", - "field": "hotel" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Price", - "field": "hotel" - }, - "directive": "relation" - }, - "argument": "fields", - "value": "[hotelId]" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Price", - "field": "hotel" - }, - "directive": "relation" - }, - "argument": "references", - "value": "[id]" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Model", - "model": "Price" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Model", - "model": "Price" - }, - "directive": "map" - }, - "argument": "", - "value": "\"price\"" - }, - { - "tag": "CreateModel", - "model": "Photo" - }, - { - "tag": "CreateField", - "model": "Photo", - "field": "id", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Photo", - "field": "id" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Photo", - "field": "id" - }, - "directive": "default" - }, - "argument": "", - "value": "autoincrement()" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Photo", - "field": "id" - }, - "directive": "id" - } - }, - { - "tag": "CreateField", - "model": "Photo", - "field": "createdAt", - "type": "DateTime", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Photo", - "field": "createdAt" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Photo", - "field": "createdAt" - }, - "directive": "default" - }, - "argument": "", - "value": "now()" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Photo", - "field": "createdAt" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Photo", - "field": "createdAt" - }, - "directive": "map" - }, - "argument": "", - "value": "\"created_at\"" - }, - { - "tag": "CreateField", - "model": "Photo", - "field": "updatedAt", - "type": "DateTime", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Photo", - "field": "updatedAt" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Photo", - "field": "updatedAt" - }, - "directive": "map" - }, - "argument": "", - "value": "\"updated_at\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Photo", - "field": "updatedAt" - }, - "directive": "updatedAt" - } - }, - { - "tag": "CreateField", - "model": "Photo", - "field": "url", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Photo", - "field": "target", - "type": "Target", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Photo", - "field": "targetId", - "type": "Int", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Photo", - "field": "targetId" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Photo", - "field": "targetId" - }, - "directive": "map" - }, - "argument": "", - "value": "\"target_id\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Model", - "model": "Photo" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Model", - "model": "Photo" - }, - "directive": "map" - }, - "argument": "", - "value": "\"photo\"" - }, - { - "tag": "CreateModel", - "model": "User" - }, - { - "tag": "CreateField", - "model": "User", - "field": "id", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "id" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "User", - "field": "id" - }, - "directive": "default" - }, - "argument": "", - "value": "autoincrement()" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "id" - }, - "directive": "id" - } - }, - { - "tag": "CreateField", - "model": "User", - "field": "createdAt", - "type": "DateTime", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "createdAt" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "User", - "field": "createdAt" - }, - "directive": "default" - }, - "argument": "", - "value": "now()" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "createdAt" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "User", - "field": "createdAt" - }, - "directive": "map" - }, - "argument": "", - "value": "\"created_at\"" - }, - { - "tag": "CreateField", - "model": "User", - "field": "updatedAt", - "type": "DateTime", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "updatedAt" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "User", - "field": "updatedAt" - }, - "directive": "map" - }, - "argument": "", - "value": "\"updated_at\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "updatedAt" - }, - "directive": "updatedAt" - } - }, - { - "tag": "CreateField", - "model": "User", - "field": "name", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "name" - }, - "directive": "unique" - } - }, - { - "tag": "CreateField", - "model": "User", - "field": "email", - "type": "String", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "email" - }, - "directive": "unique" - } - }, - { - "tag": "CreateField", - "model": "User", - "field": "password", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "provider", - "type": "Provider", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "User", - "field": "accessToken", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "accessToken" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "User", - "field": "accessToken" - }, - "directive": "map" - }, - "argument": "", - "value": "\"access_token\"" - }, - { - "tag": "CreateField", - "model": "User", - "field": "refreshToken", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "refreshToken" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "User", - "field": "refreshToken" - }, - "directive": "map" - }, - "argument": "", - "value": "\"refresh_token\"" - }, - { - "tag": "CreateField", - "model": "User", - "field": "phoneNumber", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "phoneNumber" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "User", - "field": "phoneNumber" - }, - "directive": "map" - }, - "argument": "", - "value": "\"phone_number\"" - }, - { - "tag": "CreateField", - "model": "User", - "field": "pets", - "type": "Pet", - "arity": "List" - }, - { - "tag": "CreateField", - "model": "User", - "field": "favoriteHotels", - "type": "Hotel", - "arity": "List" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "User", - "field": "favoriteHotels" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "User", - "field": "favoriteHotels" - }, - "directive": "relation" - }, - "argument": "references", - "value": "[id]" - }, - { - "tag": "CreateField", - "model": "User", - "field": "Reservation", - "type": "Reservation", - "arity": "List" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Model", - "model": "User" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Model", - "model": "User" - }, - "directive": "map" - }, - "argument": "", - "value": "\"user\"" - }, - { - "tag": "CreateModel", - "model": "Pet" - }, - { - "tag": "CreateField", - "model": "Pet", - "field": "id", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Pet", - "field": "id" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Pet", - "field": "id" - }, - "directive": "default" - }, - "argument": "", - "value": "autoincrement()" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Pet", - "field": "id" - }, - "directive": "id" - } - }, - { - "tag": "CreateField", - "model": "Pet", - "field": "userId", - "type": "Int", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Pet", - "field": "userId" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Pet", - "field": "userId" - }, - "directive": "map" - }, - "argument": "", - "value": "\"user_id\"" - }, - { - "tag": "CreateField", - "model": "Pet", - "field": "createdAt", - "type": "DateTime", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Pet", - "field": "createdAt" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Pet", - "field": "createdAt" - }, - "directive": "default" - }, - "argument": "", - "value": "now()" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Pet", - "field": "createdAt" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Pet", - "field": "createdAt" - }, - "directive": "map" - }, - "argument": "", - "value": "\"created_at\"" - }, - { - "tag": "CreateField", - "model": "Pet", - "field": "updatedAt", - "type": "DateTime", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Pet", - "field": "updatedAt" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Pet", - "field": "updatedAt" - }, - "directive": "map" - }, - "argument": "", - "value": "\"updated_at\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Pet", - "field": "updatedAt" - }, - "directive": "updatedAt" - } - }, - { - "tag": "CreateField", - "model": "Pet", - "field": "name", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Pet", - "field": "year", - "type": "Int", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Pet", - "field": "weight", - "type": "Int", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Pet", - "field": "registerNum", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Pet", - "field": "registerNum" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Pet", - "field": "registerNum" - }, - "directive": "map" - }, - "argument": "", - "value": "\"register_num\"" - }, - { - "tag": "CreateField", - "model": "Pet", - "field": "rfidCode", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Pet", - "field": "rfidCode" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Pet", - "field": "rfidCode" - }, - "directive": "map" - }, - "argument": "", - "value": "\"rfid_cd\"" - }, - { - "tag": "CreateField", - "model": "Pet", - "field": "breed", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Pet", - "field": "isNeutered", - "type": "Boolean", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Pet", - "field": "isNeutered" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Pet", - "field": "isNeutered" - }, - "directive": "map" - }, - "argument": "", - "value": "\"is_neutered\"" - }, - { - "tag": "CreateField", - "model": "Pet", - "field": "gender", - "type": "Gender", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Pet", - "field": "owner", - "type": "User", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Pet", - "field": "owner" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Pet", - "field": "owner" - }, - "directive": "relation" - }, - "argument": "fields", - "value": "[userId]" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Pet", - "field": "owner" - }, - "directive": "relation" - }, - "argument": "references", - "value": "[id]" - }, - { - "tag": "CreateField", - "model": "Pet", - "field": "reservations", - "type": "Reservation", - "arity": "List" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Model", - "model": "Pet" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Model", - "model": "Pet" - }, - "directive": "map" - }, - "argument": "", - "value": "\"pet\"" - }, - { - "tag": "CreateModel", - "model": "Reservation" - }, - { - "tag": "CreateField", - "model": "Reservation", - "field": "id", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Reservation", - "field": "id" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Reservation", - "field": "id" - }, - "directive": "default" - }, - "argument": "", - "value": "autoincrement()" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Reservation", - "field": "id" - }, - "directive": "id" - } - }, - { - "tag": "CreateField", - "model": "Reservation", - "field": "userId", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Reservation", - "field": "userId" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Reservation", - "field": "userId" - }, - "directive": "map" - }, - "argument": "", - "value": "\"user_id\"" - }, - { - "tag": "CreateField", - "model": "Reservation", - "field": "hotelId", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Reservation", - "field": "hotelId" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Reservation", - "field": "hotelId" - }, - "directive": "map" - }, - "argument": "", - "value": "\"hotel_id\"" - }, - { - "tag": "CreateField", - "model": "Reservation", - "field": "petId", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Reservation", - "field": "petId" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Reservation", - "field": "petId" - }, - "directive": "map" - }, - "argument": "", - "value": "\"pet_id\"" - }, - { - "tag": "CreateField", - "model": "Reservation", - "field": "createdAt", - "type": "DateTime", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Reservation", - "field": "createdAt" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Reservation", - "field": "createdAt" - }, - "directive": "default" - }, - "argument": "", - "value": "now()" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Reservation", - "field": "createdAt" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Reservation", - "field": "createdAt" - }, - "directive": "map" - }, - "argument": "", - "value": "\"created_at\"" - }, - { - "tag": "CreateField", - "model": "Reservation", - "field": "updatedAt", - "type": "DateTime", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Reservation", - "field": "updatedAt" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Reservation", - "field": "updatedAt" - }, - "directive": "map" - }, - "argument": "", - "value": "\"updated_at\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Reservation", - "field": "updatedAt" - }, - "directive": "updatedAt" - } - }, - { - "tag": "CreateField", - "model": "Reservation", - "field": "startDate", - "type": "DateTime", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Reservation", - "field": "startDate" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Reservation", - "field": "startDate" - }, - "directive": "map" - }, - "argument": "", - "value": "\"start_date\"" - }, - { - "tag": "CreateField", - "model": "Reservation", - "field": "endDate", - "type": "DateTime", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Reservation", - "field": "endDate" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Reservation", - "field": "endDate" - }, - "directive": "map" - }, - "argument": "", - "value": "\"end_date\"" - }, - { - "tag": "CreateField", - "model": "Reservation", - "field": "pickupTime", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Reservation", - "field": "pickupTime" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Reservation", - "field": "pickupTime" - }, - "directive": "map" - }, - "argument": "", - "value": "\"pick_up_time\"" - }, - { - "tag": "CreateField", - "model": "Reservation", - "field": "request", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Reservation", - "field": "user", - "type": "User", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Reservation", - "field": "user" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Reservation", - "field": "user" - }, - "directive": "relation" - }, - "argument": "fields", - "value": "[userId]" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Reservation", - "field": "user" - }, - "directive": "relation" - }, - "argument": "references", - "value": "[id]" - }, - { - "tag": "CreateField", - "model": "Reservation", - "field": "hotel", - "type": "Hotel", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Reservation", - "field": "hotel" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Reservation", - "field": "hotel" - }, - "directive": "relation" - }, - "argument": "fields", - "value": "[hotelId]" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Reservation", - "field": "hotel" - }, - "directive": "relation" - }, - "argument": "references", - "value": "[id]" - }, - { - "tag": "CreateField", - "model": "Reservation", - "field": "pet", - "type": "Pet", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Reservation", - "field": "pet" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Reservation", - "field": "pet" - }, - "directive": "relation" - }, - "argument": "fields", - "value": "[petId]" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Reservation", - "field": "pet" - }, - "directive": "relation" - }, - "argument": "references", - "value": "[id]" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Model", - "model": "Reservation" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Model", - "model": "Reservation" - }, - "directive": "map" - }, - "argument": "", - "value": "\"reservation\"" - } - ] -} diff --git a/prisma/migrations/20200626235211/README.md b/prisma/migrations/20200630164446-init/README.md similarity index 91% rename from prisma/migrations/20200626235211/README.md rename to prisma/migrations/20200630164446-init/README.md index e1005de..3596244 100644 --- a/prisma/migrations/20200626235211/README.md +++ b/prisma/migrations/20200630164446-init/README.md @@ -1,6 +1,6 @@ -# Migration `20200626235211` +# Migration `20200630164446-init` -This migration has been generated by boorim98 at 6/26/2020, 11:52:11 PM. +This migration has been generated at 6/30/2020, 4:44:46 PM. You can check out the [state of the schema](./schema.prisma) after the migration. ## Database Steps @@ -46,11 +46,6 @@ CREATE TABLE `petmily`.`reservation` ( PRIMARY KEY (`id`) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci -CREATE TABLE `petmily`.`reservation_payment` ( -`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ,`id` int NOT NULL AUTO_INCREMENT,`name` varchar(191) ,`reservation_id` int NOT NULL ,`updated_at` datetime(3) , - PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci - CREATE TABLE `petmily`.`review` ( `content` varchar(191) ,`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ,`hotel_id` int NOT NULL ,`id` int NOT NULL AUTO_INCREMENT,`rating` int ,`updated_at` datetime(3) ,`user_id` int NOT NULL , PRIMARY KEY (`id`) @@ -64,8 +59,6 @@ CREATE UNIQUE INDEX `user.name` ON `petmily`.`user`(`name`) CREATE UNIQUE INDEX `user.email` ON `petmily`.`user`(`email`) -CREATE UNIQUE INDEX `reservation_payment_reservation_id` ON `petmily`.`reservation_payment`(`reservation_id`) - CREATE UNIQUE INDEX `_HotelToUser_AB_unique` ON `petmily`.`_HotelToUser`(`A`,`B`) CREATE INDEX `_HotelToUser_B_index` ON `petmily`.`_HotelToUser`(`B`) @@ -84,8 +77,6 @@ ALTER TABLE `petmily`.`reservation` ADD FOREIGN KEY (`hotel_id`) REFERENCES `pet ALTER TABLE `petmily`.`reservation` ADD FOREIGN KEY (`pet_id`) REFERENCES `petmily`.`pet`(`id`) ON DELETE CASCADE ON UPDATE CASCADE -ALTER TABLE `petmily`.`reservation_payment` ADD FOREIGN KEY (`reservation_id`) REFERENCES `petmily`.`reservation`(`id`) ON DELETE CASCADE ON UPDATE CASCADE - ALTER TABLE `petmily`.`review` ADD FOREIGN KEY (`user_id`) REFERENCES `petmily`.`user`(`id`) ON DELETE CASCADE ON UPDATE CASCADE ALTER TABLE `petmily`.`review` ADD FOREIGN KEY (`hotel_id`) REFERENCES `petmily`.`hotel`(`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -99,10 +90,10 @@ ALTER TABLE `petmily`.`_HotelToUser` ADD FOREIGN KEY (`B`) REFERENCES `petmily`. ```diff diff --git schema.prisma schema.prisma -migration ..20200626235211 +migration ..20200630164446-init --- datamodel.dml +++ datamodel.dml -@@ -1,0 +1,204 @@ +@@ -1,0 +1,192 @@ +datasource mysql { + url = env("DATABASE_URL") + provider = "mysql" @@ -243,7 +234,6 @@ migration ..20200626235211 + endDate DateTime? @map("end_date") + pickupTime String? @map("pick_up_time") + request String? -+ payment Payment? + user User @relation(fields: [userId], references: [id]) + hotel Hotel @relation(fields: [hotelId], references: [id]) + pet Pet @relation(fields: [petId], references: [id]) @@ -251,17 +241,6 @@ migration ..20200626235211 + @@map("reservation") +} + -+model Payment { -+ id Int @default(autoincrement()) @id -+ reservationId Int @map("reservation_id") -+ createdAt DateTime @default(now()) @map("created_at") -+ updatedAt DateTime? @map("updated_at") @updatedAt -+ name String? -+ reservation Reservation @relation(fields: [reservationId], references: [id]) -+ -+ @@map("reservation_payment") -+} -+ +model Review { + id Int @default(autoincrement()) @id + rating Int? diff --git a/prisma/migrations/20200626235211/schema.prisma b/prisma/migrations/20200630164446-init/schema.prisma similarity index 93% rename from prisma/migrations/20200626235211/schema.prisma rename to prisma/migrations/20200630164446-init/schema.prisma index 0dea6bf..1e4afea 100644 --- a/prisma/migrations/20200626235211/schema.prisma +++ b/prisma/migrations/20200630164446-init/schema.prisma @@ -36,6 +36,7 @@ model Hotel { prices Price[] reservations Reservation[] customers User[] @relation(references: [id]) + @@map("hotel") Review Review[] } @@ -47,6 +48,7 @@ model Monitoring { updatedAt DateTime? @map("updated_at") @updatedAt name String? hotel Hotel @relation(fields: [hotelId], references: [id]) + @@map("hotel_monitoring_type") } @@ -57,6 +59,7 @@ model Service { updatedAt DateTime? @map("updated_at") @updatedAt name String? hotel Hotel @relation(fields: [hotelId], references: [id]) + @@map("hotel_service") } @@ -70,6 +73,7 @@ model Price { size Size? price Int? hotel Hotel @relation(fields: [hotelId], references: [id]) + @@map("price") } @@ -80,6 +84,7 @@ model Photo { url String? target Target? targetId Int? @map("target_id") + @@map("photo") } @@ -97,7 +102,9 @@ model User { pets Pet[] favoriteHotels Hotel[] @relation(references: [id]) Reservation Reservation[] + @@map("user") + Review Review[] } @@ -116,6 +123,7 @@ model Pet { gender Gender? owner User? @relation(fields: [userId], references: [id]) reservations Reservation[] + @@map("pet") } @@ -130,21 +138,11 @@ model Reservation { endDate DateTime? @map("end_date") pickupTime String? @map("pick_up_time") request String? - payment Payment? user User @relation(fields: [userId], references: [id]) hotel Hotel @relation(fields: [hotelId], references: [id]) pet Pet @relation(fields: [petId], references: [id]) - @@map("reservation") -} -model Payment { - id Int @default(autoincrement()) @id - reservationId Int @map("reservation_id") - createdAt DateTime @default(now()) @map("created_at") - updatedAt DateTime? @map("updated_at") @updatedAt - name String? - reservation Reservation @relation(fields: [reservationId], references: [id]) - @@map("reservation_payment") + @@map("reservation") } model Review { @@ -157,12 +155,14 @@ model Review { hotelId Int @map("hotel_id") user User @relation(fields: [userId], references: [id]) hotel Hotel @relation(fields: [hotelId], references: [id]) + @@map("review") } enum Gender { MALE @map("수컷") FEMAIL @map("암컷") + @@map("gender") } @@ -170,6 +170,7 @@ enum Target { PET @map("pet") USER @map("user") HOTEL @map("hotel") + @@map("target") } @@ -177,6 +178,7 @@ enum Size { SMALL @map("small") MEDIUM @map("medium") LARGE @map("large") + @@map("size") } @@ -185,5 +187,6 @@ enum Provider { NAVER @map("naver") GOOGLE @map("google") FACEBOOK @map("facebook") + @@map("provider") } diff --git a/prisma/migrations/20200626235211/steps.json b/prisma/migrations/20200630164446-init/steps.json similarity index 93% rename from prisma/migrations/20200626235211/steps.json rename to prisma/migrations/20200630164446-init/steps.json index 428d85e..98dc757 100644 --- a/prisma/migrations/20200626235211/steps.json +++ b/prisma/migrations/20200630164446-init/steps.json @@ -3265,13 +3265,6 @@ "type": "String", "arity": "Optional" }, - { - "tag": "CreateField", - "model": "Reservation", - "field": "payment", - "type": "Payment", - "arity": "Optional" - }, { "tag": "CreateField", "model": "Reservation", @@ -3433,261 +3426,6 @@ "argument": "", "value": "\"reservation\"" }, - { - "tag": "CreateModel", - "model": "Payment" - }, - { - "tag": "CreateField", - "model": "Payment", - "field": "id", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Payment", - "field": "id" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Payment", - "field": "id" - }, - "directive": "default" - }, - "argument": "", - "value": "autoincrement()" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Payment", - "field": "id" - }, - "directive": "id" - } - }, - { - "tag": "CreateField", - "model": "Payment", - "field": "reservationId", - "type": "Int", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Payment", - "field": "reservationId" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Payment", - "field": "reservationId" - }, - "directive": "map" - }, - "argument": "", - "value": "\"reservation_id\"" - }, - { - "tag": "CreateField", - "model": "Payment", - "field": "createdAt", - "type": "DateTime", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Payment", - "field": "createdAt" - }, - "directive": "default" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Payment", - "field": "createdAt" - }, - "directive": "default" - }, - "argument": "", - "value": "now()" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Payment", - "field": "createdAt" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Payment", - "field": "createdAt" - }, - "directive": "map" - }, - "argument": "", - "value": "\"created_at\"" - }, - { - "tag": "CreateField", - "model": "Payment", - "field": "updatedAt", - "type": "DateTime", - "arity": "Optional" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Payment", - "field": "updatedAt" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Payment", - "field": "updatedAt" - }, - "directive": "map" - }, - "argument": "", - "value": "\"updated_at\"" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Payment", - "field": "updatedAt" - }, - "directive": "updatedAt" - } - }, - { - "tag": "CreateField", - "model": "Payment", - "field": "name", - "type": "String", - "arity": "Optional" - }, - { - "tag": "CreateField", - "model": "Payment", - "field": "reservation", - "type": "Reservation", - "arity": "Required" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Field", - "model": "Payment", - "field": "reservation" - }, - "directive": "relation" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Payment", - "field": "reservation" - }, - "directive": "relation" - }, - "argument": "fields", - "value": "[reservationId]" - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Field", - "model": "Payment", - "field": "reservation" - }, - "directive": "relation" - }, - "argument": "references", - "value": "[id]" - }, - { - "tag": "CreateDirective", - "location": { - "path": { - "tag": "Model", - "model": "Payment" - }, - "directive": "map" - } - }, - { - "tag": "CreateArgument", - "location": { - "tag": "Directive", - "path": { - "tag": "Model", - "model": "Payment" - }, - "directive": "map" - }, - "argument": "", - "value": "\"reservation_payment\"" - }, { "tag": "CreateModel", "model": "Review" diff --git a/prisma/migrations/migrate.lock b/prisma/migrations/migrate.lock index 777560f..1e51993 100644 --- a/prisma/migrations/migrate.lock +++ b/prisma/migrations/migrate.lock @@ -1,3 +1,3 @@ # Prisma Migrate lockfile v1 -20200629222336 \ No newline at end of file +20200630164446-init \ No newline at end of file diff --git a/src/controllers/PetController.ts b/src/controllers/PetController.ts index 93715d1..8839687 100644 --- a/src/controllers/PetController.ts +++ b/src/controllers/PetController.ts @@ -4,7 +4,10 @@ import { PrismaClient } from '@prisma/client'; import jwtMiddleware, { JwtUserData } from '../utils/AuthHelper'; import { PetProvider, PetRegisterData } from '../providers/PetProvider'; import { PetService } from '../services/PetService'; -import { NotRegisteredPetError } from '../errors/PetError'; +import { + NotRegisteredPetError, + DuplicatedPetNameError, +} from '../errors/PetError'; import { JsonController, Get, @@ -14,6 +17,7 @@ import { UploadedFiles, Req, } from 'routing-controllers'; +import { PhotoService } from '../services/PhotoService'; export interface SignUpPetRequest { data: PetData[]; } @@ -26,6 +30,8 @@ export interface PetData { breed: string; isNeutered: string; gender: string; + weight?: number; + photoUrl?: string; } export interface PetResponse { @@ -48,21 +54,33 @@ export class PetController extends BaseController { private databaseClient: PrismaClient; private petService: PetService; private petProvider: PetProvider; + private photoService: PhotoService; constructor() { super(); this.databaseClient = new PrismaClient(); this.petService = new PetService(); + this.photoService = new PhotoService(); this.petProvider = new PetProvider(); } + @Get('/') - public index() { - return 'Hello! This is pets🐶 page'; + @UseBefore(jwtMiddleware) + public async getPetInfo(@Req() request: express.Request) { + const userInfo: JwtUserData = request.user; + const myPets = await this.petService.getUserPet(userInfo.id); + console.log(64, myPets); + const response: PetResponse = { + status: 'success', + message: 'Succeed in getting pet information', + data: myPets, + }; + return response; } @Post('/') @UseBefore(jwtMiddleware) - public async createPet( - @UploadedFiles('photo') files: File[], + public async createPetInfo( + @UploadedFiles('photo') files: PhotoUploadRequest[], @Body() data: PetData[], @Req() request: express.Request ) { @@ -70,17 +88,31 @@ export class PetController extends BaseController { const userInfo: JwtUserData = request.user; const petInfo = []; + const petNames = new Set(); + + for (const idx in petData) { + const prevSize = petNames.size; + petNames.add(petData[idx].petName); + if (prevSize === petNames.size) throw new DuplicatedPetNameError(); + + const newPet = await this.petService.createUserPet( + userInfo.id, + petData[idx] + ); + const petPhoto = await this.photoService.createPetPhoto( + newPet.id, + files[idx] + ); - for (const info of petData) { - console.log(79, userInfo); - const newPet = await this.petService.createUserPet(userInfo.id, info); + petNames.add(newPet.name); - petInfo.push(newPet); + const info = { ...newPet, ...petPhoto }; + petInfo.push(info); } const response: PetResponse = { status: 'success', - message: 'Success User Pet Creation', + message: 'Succeed in creating pet information', data: petInfo, }; @@ -88,7 +120,7 @@ export class PetController extends BaseController { } @Post('/check') - public async checkPet(@Body() petData: PetData) { + public async checkPetInfo(@Body() petData: PetData) { const { registerNumber } = petData; const registerData: PetRegisterData = await this.petProvider.getRegisterPetData( registerNumber @@ -97,7 +129,7 @@ export class PetController extends BaseController { const response: PetResponse = { status: 'success', - message: 'Success check registered pet', + message: 'Succeed in checking registered pet information', data: registerData, }; diff --git a/src/controllers/UserController.ts b/src/controllers/UserController.ts index 32ed1a5..f790ac6 100644 --- a/src/controllers/UserController.ts +++ b/src/controllers/UserController.ts @@ -1,3 +1,4 @@ +import express from 'express'; import { BaseController } from './BaseController'; import { UserNotFoundError } from '../errors/UserError'; @@ -8,7 +9,8 @@ import { Post, Body, UseBefore, - BodyParam, + Req, + UploadedFile, } from 'routing-controllers'; import { UserService } from '../services/UserService'; import { PhotoService } from '../services/PhotoService'; @@ -16,6 +18,7 @@ import { PhotoService } from '../services/PhotoService'; export interface OauthSignUpData { nickname: string; phoneNumber: string; + profileImage: string | PhotoUploadRequest; } export interface OauthSignUpRequest { @@ -27,7 +30,7 @@ export interface GeneralSignUpData { nickname: string; phoneNumber: string; email: string; - photoUrl: string; + photoUrl?: string; password: string; } @@ -50,6 +53,15 @@ export interface JwtSignUpResponse { }; } +export interface PhotoUploadRequest { + fieldname: string; + originalname: string; + encoding: string; + mimetype: string; + buffer: Buffer; + size: number; +} + //TODO: User 정보 수정(PUT) 그리고 탈퇴(DELETE) 구현 @JsonController('/user') export class UserController extends BaseController { @@ -64,7 +76,8 @@ export class UserController extends BaseController { @Get('/') @UseBefore(jwtMiddleware) - public async index(@BodyParam('user') user: JwtUserData) { + public async index(@Req() request: express.Request) { + const user: JwtUserData = request.user; const userData = await this.userService.findUserByEmail(user.email); if (!userData) throw new UserNotFoundError(user.email); @@ -84,21 +97,25 @@ export class UserController extends BaseController { //TODO: 닉네임 중복확인 //TODO: signUpData에 모든 정보가 들어왔는지 Validation check @Post('/') - public async createUser(@Body() signUpData: string) { + public async createUser( + @Body() signUpData: string, + @UploadedFile('profileImage') file: PhotoUploadRequest + ) { // TODO: signUpData validation check - - // 먼저 어디서 들어왔는지 체크 (일반 로그인? 카카오 로그인?) const bodyData = JSON.parse(JSON.stringify(signUpData)); - const id = bodyData.userId; const data = bodyData.data; - - const signUpUser = - id === undefined - ? await this.userService.createGeneralUser(data) - : await this.userService.updateSignUpData(id, data); - - if (!signUpData) { - //TODO: Database error handling + const photo = data.profileImage === undefined ? file : data.profileImage; + + let signUpUser; + + if (bodyData.userId === undefined) { + signUpUser = await this.userService.createGeneralUser(data); + if (photo !== undefined) + await this.photoService.createUserPhoto(signUpUser.id, photo); + } else { + const id = parseInt(bodyData.userId); + signUpUser = await this.userService.updateSignUpData(id, data); + await this.photoService.createUserPhoto(signUpUser.id, photo); } const token = signJwtToken(signUpUser.id, signUpUser.email); diff --git a/src/errors/BaseError.ts b/src/errors/BaseError.ts index 35c4198..f7f16bf 100644 --- a/src/errors/BaseError.ts +++ b/src/errors/BaseError.ts @@ -1,13 +1,5 @@ +import { HttpError } from 'routing-controllers'; export interface ErrorResponse { error: string; message: string; } - -export class BaseError extends Error { - /* - constructor(name?: string, message?: string) { - super(message); // 'Error' breaks prototype chain here - Object.setPrototypeOf(this, new.target.prototype); // restore prototype chain - } - */ -} diff --git a/src/errors/PetError.ts b/src/errors/PetError.ts index 22e1034..d095b86 100644 --- a/src/errors/PetError.ts +++ b/src/errors/PetError.ts @@ -1,3 +1,5 @@ +// 이미 회원 가입된 이메일로 다시 회원가입을 신청하려고 할 때(409 Conflict) +import { HttpError } from 'routing-controllers'; import { NotFoundError } from 'routing-controllers'; import { ErrorResponse } from '../errors/BaseError'; @@ -14,3 +16,17 @@ export class NotRegisteredPetError extends NotFoundError { }; } } + +export class DuplicatedPetNameError extends HttpError { + constructor() { + super(409, 'Duplicated pet name'); + Object.setPrototypeOf(this, DuplicatedPetNameError.prototype); + } + + public toJSON(): ErrorResponse { + return { + error: this.message, + message: 'Duplicated pet name is not allowed in same user', + }; + } +} diff --git a/src/errors/UserError.ts b/src/errors/UserError.ts index d8db597..dc005e1 100644 --- a/src/errors/UserError.ts +++ b/src/errors/UserError.ts @@ -33,4 +33,20 @@ export class UserNotFoundError extends NotFoundError { }; } } + +export class DuplicatedInformation extends HttpError { + private reason: string; + constructor(reason: string) { + super(409, 'Duplicated User Information'); + this.reason = reason.split('\n\n')[1]; + Object.setPrototypeOf(this, DuplicatedInformation.prototype); + } + + public toJSON(): ErrorResponse { + return { + error: this.message, + message: this.reason, + }; + } +} // OAuth를 사용할 때 엑세스 토큰(access token)이 유효하지 않을 경우 (403 Forbidden) diff --git a/src/services/PetService.ts b/src/services/PetService.ts index c751788..df5934d 100644 --- a/src/services/PetService.ts +++ b/src/services/PetService.ts @@ -14,6 +14,27 @@ export class PetService extends BaseService { this.databaseClient = new PrismaClient(); } + public async getUserPet(userId: number) { + const userPets = await this.databaseClient.pet.findMany({ + where: { userId }, + }); + const result = []; + for (const info of userPets) { + const petInfo: PetData = { + petName: info.name!, + registerNumber: info.registerNum!, + rfidCode: info.rfidCode!, + birthYear: info.year!.toString(), + breed: info.breed!, + isNeutered: info.isNeutered!.toString(), + gender: info.gender!, + weight: info.weight!, + }; + result.push(petInfo); + } + return result; + } + public async createUserPet(userId: number, petData: PetData) { petData.gender = petData.gender === '수컷' ? 'MALE' : 'FEMAIL'; const result = await this.databaseClient.pet.create({ @@ -28,14 +49,6 @@ export class PetService extends BaseService { owner: { connect: { id: userId } }, }, }); - const photoResult = await this.databaseClient.photo.create({ - data: { - url: data.photoUrl, - target: 'PET', - targetId: petResult.id, - }, - }); - const result = { ...petResult, ...photoResult }; return result; } } diff --git a/src/services/PhotoService.ts b/src/services/PhotoService.ts index 3d2c893..ae9f782 100644 --- a/src/services/PhotoService.ts +++ b/src/services/PhotoService.ts @@ -2,6 +2,7 @@ import { BaseService } from './BaseService'; import { PrismaClient } from '@prisma/client'; import { PhotoUploadRequest } from '../controllers/PhotoController'; +import { NotSupportedTypeError, UploadImageError } from '../errors/PhotoError'; import config from '../config'; import moment from 'moment'; import AWS from 'aws-sdk'; @@ -10,12 +11,13 @@ type Target = 'PET' | 'USER' | 'HOTEL'; export class PhotoService extends BaseService { private databaseClient: PrismaClient; + private allowedMimeTypes: string[]; private S3: AWS.S3; constructor() { super(); this.databaseClient = new PrismaClient(); - + this.allowedMimeTypes = ['image/png', 'image/jpeg', 'image/bmp']; this.S3 = new AWS.S3({ accessKeyId: config.auth.aws.accessKey, secretAccessKey: config.auth.aws.secretKey, @@ -52,4 +54,56 @@ export class PhotoService extends BaseService { console.log(52, result[result.length - 1]); return result[result.length - 1]; } + + public async createPetPhoto(petId: number, file: PhotoUploadRequest) { + if (!this.allowedMimeTypes.includes(file.mimetype)) + throw new NotSupportedTypeError(file.mimetype); + + const upload = await this.uploadPhotoS3('pet', file); + + if (upload instanceof Error) throw new UploadImageError(); + + const result = await this.databaseClient.photo.create({ + data: { + target: 'PET', + targetId: petId, + url: upload['Location'], + }, + }); + + return { photoUrl: result.url }; + } + + public async createUserPhoto( + userId: number, + file: PhotoUploadRequest | string + ) { + if (typeof file === 'string') { + const result = await this.databaseClient.photo.create({ + data: { + target: 'USER', + targetId: userId, + url: file, + }, + }); + return result; + } + + if (!this.allowedMimeTypes.includes(file.mimetype)) + throw new NotSupportedTypeError(file.mimetype); + + const upload = await this.uploadPhotoS3('user', file); + + if (upload instanceof Error) throw new UploadImageError(); + + const result = await this.databaseClient.photo.create({ + data: { + target: 'USER', + targetId: userId, + url: upload['Location'], + }, + }); + + return { photoUrl: result.url }; + } } diff --git a/src/services/UserService.ts b/src/services/UserService.ts index 3ddc26e..1dbdd42 100644 --- a/src/services/UserService.ts +++ b/src/services/UserService.ts @@ -1,6 +1,7 @@ // Database 접근하기 import { BaseService } from './BaseService'; import { PrismaClient } from '@prisma/client'; +import { DuplicatedInformation } from '../errors/UserError'; import { OauthSignUpData, GeneralSignUpData, @@ -10,6 +11,15 @@ import { hashPassword } from '../utils/AuthHelper'; type Provider = 'KAKAO' | 'NAVER' | 'GOOGLE' | 'FACEBOOK'; +export interface PhotoUploadRequest { + fieldname: string; + originalname: string; + encoding: string; + mimetype: string; + buffer: Buffer; + size: number; +} + export class UserService extends BaseService { private databaseClient: PrismaClient; @@ -19,26 +29,23 @@ export class UserService extends BaseService { } public async createGeneralUser(signUpData: GeneralSignUpData) { - const { nickname, phoneNumber, email, password, photoUrl } = signUpData; + console.log(34, signUpData); + const { nickname, phoneNumber, email, password } = signUpData; const safePassword = await hashPassword(password); - console.log(password, safePassword); - const userResult = await this.databaseClient.user.create({ - data: { - name: nickname, - phoneNumber: phoneNumber, - email: email, - password: safePassword, - }, - }); - const photoResult = await this.databaseClient.photo.create({ - data: { - url: photoUrl, - target: 'USER', - targetId: userResult.id, - }, - }); - const result = { ...userResult, ...photoResult }; - return result; + + try { + const userResult = await this.databaseClient.user.create({ + data: { + name: nickname, + phoneNumber: phoneNumber, + email: email, + password: safePassword, + }, + }); + return userResult; + } catch (e) { + throw new DuplicatedInformation(e.message); + } } public async createOauthUser(