Arun Setty Kodavali
06/20/2022, 12:08 PMArun Setty Kodavali
06/20/2022, 12:08 PMUnhandledPromiseRejectionWarning: TypeError: Cannot read property 'findMany' of undefined
If I restart the server I have, it is working fine. How to actually do CRUD operations after generation without restarting the server?
Thanks in advance, Cheers!Yunbo
06/20/2022, 7:25 PMnpx prisma dev
to create migration step which i think its procedure step is create migration -> apply migration -> npx prisma generate.
what's the procedure difference between npx prisma dev
and npm prisma deploy
?Manthan Mallikarjun
06/20/2022, 9:08 PMHello world #welcome #message #other
and store it. Later they should be able to quickly search by the hashtag. However the string is also editable and I can forsee it being edited multiple times in its lifetime. I was initially thinking of having a messages
table and a message_tags
table. However I realize that since the string can be edited and #welcome
can easily become #howdy
, keeping the message_tags
table in sync might be difficult. In this case am I better off just putting a tags
array column on the messages
table and indexing it?Robert Cornacchia
06/21/2022, 1:26 AMmodel Debate {
id Int @id @default(autoincrement())
topic String
status DebateStatus @default(UPCOMING)
createdAt DateTime @default(now())
isDaily Boolean @default(false)
start DateTime?
end DateTime?
author User @relation("UserAuthorsDebate", fields: [authorId], references: [id])
authorId Int
posts Post[]
upvotedBy User[] @relation("UserUpvotesDebate", references: [id])
poll Poll?
revisedPoll Poll? <------------------------------- Want to add this!
}
model Poll {
id Int @id @default(autoincrement())
debate Debate @relation(fields: [debateId], references: [id])
debateId Int @unique
options PollOption[]
}
KIM SEI HOON
06/21/2022, 2:18 AMBartosz Borycki
06/21/2022, 6:26 AMmodel User {
id String @id @unique @default(cuid())
user String @unique
email String @unique
first_name String?
last_name String?
skills Skills[]
...
}
model Skills {
id String @id @unique @default(cuid())
can_play User[]
type SkillsList
}
When I try to "register user" i want to connect new user with Skills... Here is my code for create user right now:
const result = await prisma.user.create({
data: {
user: user,
email: email,
password: password,
first_name: first_name,
last_name: last_name,
skills: {
connectOrCreate: skills.map((id: string) => ({
where: { id: id },
})),
},
},
});
Skills is passing in string array with ID of skill, but I've got error:
Unknown arg `where` in data.skills.connect.0.where for type SkillsWhereUniqueInput. Did you mean `id`? Available args:
type SkillsWhereUniqueInput {
id?: String
}
Anyone can help me with this?Benjamin Cohen Solal
06/21/2022, 7:13 AMdatasource db {
provider = "mysql"
host = env("DATABASE_HOST")
port = env("DATABASE_PORT")
...
}
Instead of:
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
...
}
Thank youDenis
06/21/2022, 10:12 AMMischa
06/21/2022, 7:47 PMut dev
06/21/2022, 9:19 PMNathan Froese
06/21/2022, 10:01 PMVin Yap
06/22/2022, 2:14 AMdb pull
and prisma generate
the indexes gone, is this normal?Yunbo
06/22/2022, 2:27 AM@relation("accountsTojobs_account_id")
in schema.prisma )
2. account has one create_job_id
( @relation("accounts_create_job_idTojobs", fields: [create_job_id], references: [id])
in schema.prisma )
I'm trying to create a job -> an account
according to prisma client relation queries documentation,
when i create a job
and include account
( code below ), i shouldn't have to specify create_job_id
in account object since i won't know the id until its creation.
but the vs code throws an error saying create_job_id
is required field.
Error Message
Type '{ email: string; }' is not assignable to type 'Without<AccountUncheckedCreateWithoutJobsInput, AccountCreateWithoutJobsInput> & AccountCreateWithoutJobsInput'.
my gut tells me i'm missing something on schema file.
Could anyone take a look at this and give me some feedback?
Thanks in advance,
schema.prisma
model Account {
id Int @id @default(autoincrement())
email String
create_job_id Int
create_account_job Job @relation("accounts_create_job_idTojobs", fields: [create_job_id], references: [id])
jobs Job[] @relation("accountsTojobs_account_id")
@@map("accounts")
}
model Job {
id Int @id @default(autoincrement())
title String?
status String @default("pending")
account_id Int?
account Account? @relation("accountsTojobs_account_id", fields: [account_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "jobs_account_id_fkey")
accounts Account[] @relation("accounts_create_job_idTojobs")
@@map("jobs")
}
code :
account create object throws an error unless i add create_job_id which i won't know until parent(job) is created
prisma.job.create({
data: {
title: `Create an account`,
status: `PENDING`,
account: {
create: {
email: `<mailto:hello@test.com|hello@test.com>`,
// create_job_id : ??? i shouldn't have to add this line
},
},
},
});
Keshav Tangri
06/22/2022, 3:45 AMPriyanshi Gupta (YB)
06/22/2022, 11:18 AMTakis Karyadis
06/22/2022, 1:11 PMTakis Karyadis
06/22/2022, 1:11 PMMoin Akhter
06/22/2022, 1:38 PMasync getSignedUrl(query, res) {
try {
res.set('Access-Control-Allow-Origin', '<http://localhost:3000>');
const [url] = await storage
.bucket('my-pandume-bucket')
.file(query.fileName)
.getSignedUrl({
action: 'resumable',
version: 'v4',
expires: Date.now() + 12 * 60 * 60 * 1000,
contentType: 'application/octet-stream',
});
return res.json({
url,
});
} catch (error) {
throw new HttpException(
error.message || error.response || error,
HttpStatus.BAD_REQUEST,
);
}
}
Now i want to use signedUrl given by this endpoint on front end for resumable upload.Now inorder to used it as resumable according to documetation we have to hit a post request using this signedUrl that will give us SessionUrl this session url will be used for resumable upload but when i'm hitting post request using signedUrl which i got from backed refer to above code i'm getting this error.
FRONT END CODE:-
const uploadChunk = useCallback(
(readerEvent) => {
axios({
method: "POST",
url, ===> Reffering signedUrl which we got from backend code .
})
.then((res) => {
console.log(res.data);
})
.catch((err) => {
console.log(err);
});
},
[url]
);
Access to XMLHttpRequest at 'https://storage.googleapis.com/blahblahbla...' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Than using gsutils my cors config is this:
[{"maxAgeSeconds": 3600, "method": ["GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS"], "origin": ["<http://localhost:3000>"], "responseHeader": ["Content-Type", "Authorization", "x-goog-resumable", "Access-Control-Allow-Origin"]}]
Than why i'm getting this error any idea please.mans
06/22/2022, 4:45 PMconst cart = await prisma.cart.update({
where: {
id: dbUser.cartId,
},
data: {
Items: {
create: {
product: {
connect: {
id: parseInt(body.productId),
},
},
quantity: parseInt(body.quantity) || 1,
},
},
totalPrice: 12,
},
});
res.json(cart);
});
Here is a part of my schema
model User {
id Int @id @default(autoincrement())
username String @unique
password_hash String
role Role @default(USER)
orders Order[]
cart Cart @relation(fields: [cartId], references: [id])
cartId Int
}
model Cart {
id Int @id @default(autoincrement())
Items CartItem[]
totalPrice Float @default(0)
User User[]
}
model CartItem {
id Int @id @default(autoincrement())
Order Order? @relation(fields: [orderId], references: [id])
orderId Int?
product Product @relation(fields: [productId], references: [id])
productId Int @unique
Cart Cart? @relation(fields: [cartId], references: [id])
cartId Int?
quantity Int @default(1)
}
Olawale Mayor
06/22/2022, 7:08 PMHector Grecco
06/23/2022, 1:35 AMJohn Smeeth
06/23/2022, 4:12 AMupdateMany()
got this error on prisma.updateManyTransaction. Provided List<Json>, expected TransactionUpdateManyMutationInput or TransactionUncheckedUpdateManyInput:
my code is
const updatedTxs = await prisma.transaction.updateMany({
where: {
id: {
in: TxIds,
},
},
data: {
status: 'SUCCESS'
},
});
what wrong with me?Teun
06/23/2022, 4:38 AMsagar lama
06/23/2022, 4:56 AMmodel Course {
id Int @id @default(autoincrement())
// ...
fee Fee[]
@@map("courses")
}
model Fee {
id Int @id @default(autoincrement())
course_id Int
course Course @relation(fields: [course_id], references: [id])
feeItems FeeItems[]
// ...
@@map("fees")
}
model FeeItems {
id Int @id @default(autoincrement())
amount Float
number_of_installment Int
fee_id Int
fee Fee @relation(fields: [fee_id], references: [id])
// ...
@@map("fee_items")
}
I'm trying filter course based on the sum of fee items
What's the best way to do it?John Smeeth
06/23/2022, 5:03 AMconst ids = ["id1", "id2"]
So how can i pass it to `prisma.$executeRaw`UPDATE users SET level=1 WHERE id IN (ids)`` ? thank youuser
06/23/2022, 9:00 AMuser
06/23/2022, 9:00 AMuser
06/23/2022, 9:00 AMBG
06/23/2022, 9:37 AM