Aleks Stepančič
07/16/2022, 1:32 PMOmar
07/17/2022, 5:42 PMWRAP
or EXTEND
. More grouping behaviors will be added soon.
Feel free to try it here: https://github.com/omar-dulaimi/prisma-custom-models-generatorJannis Milz
07/17/2022, 8:17 PMRoland Sankara
07/19/2022, 5:41 PMschema.prisma
file?
For example:
Given DEVELOPMENT, TEST, PRODUCTION environments, I would maybe create this kind of logic;
const { DEVELOPMENT, PRODUCTION, LOCAL } = require("./envTypes");
let DB_URL;
switch (process.env.NODE_ENV)
{ case DEVELOPMENT:
DB_URL = process.env.DB_URL_DEV;
break;
case PRODUCTION:
DB_URL = process.env.DB_URL_PROD;
break;
case LOCAL:
DB_URL = process.env.DB_URL_LOC;
break;
default:
DB_URL = process.env.DB_URL;
}
kuksik
07/20/2022, 11:34 AMid
described as cuid
. Database - postgres.
My question: how i can set cuid
in the custom migration? Or i should do it in another way?Will
07/20/2022, 3:54 PMJayek
07/20/2022, 8:36 PM.env
defined in root directory of my repository where prisma is located in packages/prisma-db
. I struggling with this monorepo hell for hours now.Michael Jay
07/22/2022, 12:47 PMGaurav Sharan
07/25/2022, 11:35 AMIbu Madha
07/26/2022, 1:58 PMOskar
07/27/2022, 11:04 AMprisma.post.findMany()
when used with PostgreSQL it'll search for <http://public.post|public.post>
table. But in my case I have a different SQL schema. Where can I define this? I already added ?schema=myschema
to the DATABASE_URL
and prisma db pull
works fine for my custom schema.Sai Krishna
08/03/2022, 9:25 AMKIM SEI HOON
08/05/2022, 5:27 AM.node
engine file and schema.prisma
file exists, but when built, .node, schema.prisma
There is no prisma file and an error occurs during deployment. Does anyone have the same symptoms as me? Or is there any action needed to resolve this issue? Thank you!
my develop info
prisma ver: 4.1.1
prisma client 4.1.1
database: postgres SQL
yarn workspace v1Michael Jay
08/05/2022, 7:22 PMAlex Vilchis
08/06/2022, 9:39 PMAdônis Uessler
08/07/2022, 10:05 PMJaksa Malisic
08/08/2022, 12:42 PMPrismaClient
generic types without generating client itself? By “generic types” I mean the type of prisma.<anything>.<I’m trying to access type of this>, example:
const count = await prisma[camelCase(options.name)].count(params);
The catch here is that I can’t generate the client because I’m writing a backend library, so basically client gets generated in consumption context (a microservice) and I don’t need any of entity specific stuff, since my specific usecase is to build a very generic crud systemDeepak Guptha S
08/10/2022, 9:47 AMGoLang
Or how to perform transaction for multiple records (insertion, updation or deletion) using executeRaw
Is there any examples or documentation link ?Jeffr
08/11/2022, 8:11 AMTaras Protchenko
08/11/2022, 10:09 AMQuentin Gilon
08/12/2022, 3:52 PMVictor Lombardi
08/12/2022, 4:20 PMAdam
08/12/2022, 6:01 PMRichard
08/14/2022, 11:39 AMGustavo
08/23/2022, 9:58 AMargs
seems to be an object, and you're trying to access the property where
and the property id
from where
which seems to be another object.
For this then you would need to declare the type at the parameter level so that TS knows what to expect when you want to use args
e.g.
type declaration in line:
.... = async ({ args: { where: { id: number } } }) => {
...
}
Or:
type MyWhere = {
id: number;
};
type MyArgs = {
where: MyWhere;
};
.... = async ({ args: MyArgs } }) => {
...
}
hope it makes sense 🙂
I'd highly suggest to take on a TS course, this is interactive one:
https://www.codecademy.com/learn/learn-typescriptRohan Rajpal
08/23/2022, 12:06 PMonly if
a record exists?
Currently I have to first check if it exists & then update, can we do it in one query with prisma? One option is ofcourse try-catch but was curious if some better method existsSongkeys
08/24/2022, 1:35 AMNurul
08/26/2022, 6:18 AMMoheb Dabilkar
08/26/2022, 5:41 PMMoheb Dabilkar
08/26/2022, 5:48 PMgenerator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
email String @unique
firstName String
lastName String?
birthDate DateTime
phoneNumber Int @unique
verified Boolean @default(false)
address Address[]
password String @default("None")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Owner {
id Int @id @default(autoincrement())
email String @unique
firstName String
lastName String?
birthDate DateTime
phoneNumber Int @unique
verified Boolean @default(false)
address Address[]
restaurantId Int[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Admin {
id Int @id @default(autoincrement())
email String @unique
firstName String
lastName String?
birthDate DateTime
phoneNumber Int @unique
verified Boolean @default(false)
address Address[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Address {
id Int @id @default(autoincrement())
User User? @relation(fields: [userId], references: [id])
userId Int?
line1 String
line2 String
area String
city String
type AddressType @default(HOME)
Owner Owner? @relation(fields: [ownerId], references: [id])
ownerId Int?
Admin Admin? @relation(fields: [adminId], references: [id])
adminId Int?
}
enum AddressType {
HOME
OFFICE
OTHER
}
Order Service:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Order {
id Int @id @default(autoincrement())
user Int
rider Int?
restaurant Restaurant @relation(fields: [restaurantId], references: [id])
restaurantId Int
orderPickedTime DateTime?
orderDeliveredTime DateTime?
total Int
deliveryFee Int
couponDiscount Int
finalTotal Int
dishes Dishes[]
orderStatus ORDER_STATUS @default(CREATED)
address Address @relation(fields: [addressId], references: [id])
addressId Int
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Address {
id Int @id @default(autoincrement())
line1 String
line2 String
area String
city String
userId Int[]
order Order[]
Restaurant Restaurant? @relation(fields: [restaurantId], references: [id])
restaurantId Int? @unique
type ADDRESS_TYPE @default(HOME)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Restaurant {
id Int @id @default(autoincrement())
name String
vegOnly Boolean @default(false)
ownerId Int
dishes Dishes[]
address Address?
restaurantStatus CURRENT_STATUS @default(OFFLINE)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Order Order[]
}
model Dishes {
id Int @id @default(autoincrement())
name String
veg Boolean @default(false)
glutenFree Boolean @default(false)
order Order[]
category category[]
restaurant Restaurant @relation(fields: [restaurantId], references: [id])
restaurantId Int
cost Int
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model category {
id Int @id @default(autoincrement())
name String @unique
dishes Dishes[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
enum ORDER_STATUS {
CREATED
PICKEDUP
DELIVERED
CANCELLED
}
enum DISH_STATUS {
AVAILABLE
UNAVAILABLE
}
enum CURRENT_STATUS {
OFFLINE
ONLINE
}
enum ADDRESS_TYPE {
HOME
OFFICE
RESTAURANT
OTHER
}