Chris Tsongas
01/05/2022, 5:09 PMCaleb
01/05/2022, 6:56 PMRichard Kaufman-López
01/05/2022, 8:18 PMparams.args.where.deletedAt = null
, but that throws an error because
Argument where of type PostWhereUniqueInput needs exactly one argument, but you provided id and deletedAt. Please choose one.
The first idea that comes to mind is to intercept the call, check if the resource exists or not, then replace the action with create
or update
, but honestly, this doesn’t sound right.Aryan Beezadhur
01/05/2022, 9:36 PMconst foo = await prisma.table...
I don't get recommendations, only in the file where I created the Prisma instance. How do I get around this, and will it be fixed?Taylor Cantwell
01/06/2022, 6:18 AM${
cursor
`? WHERE id > ${cursor}
ORDER BY id ASC
`LIMIT ${actualLimit}``
`: ORDER BY id ASC
`LIMIT ${actualLimit}``
}
``;`Ivan
01/06/2022, 10:01 AMprisma.texture.findMany()
invocation:`
`Can't reach database server at `my credentials`:`5432``
`Please make sure your database server is running at `my credentials`:`5432`.`
The databse is not paused. Someone know why this happen?Julien Goux
01/06/2022, 11:03 AMSiemen Blok
01/06/2022, 1:16 PMheroku config:get DATABASE_URL -s >> .env
It saves the correct url to my local .env file. So the correct environmental variable is there and is begint used, just not by the Prisma Client.
Edit3:
So I resolved it by canning the Heroku app and starting from scratch, now I just hope this doesn't happen when my app goes to production 🤞Max T
01/06/2022, 2:07 PM.upsert()
function to check if a user exists, otherwise I create one. However it appears this query is taking upwards of 30 seconds, meaning the user is stuck on the OAuth consent screen for about that long waiting to be logged in. Any reason or fix for this?Shmuel
01/06/2022, 3:46 PM.create(
or do you have the back-end build it up?
Say for example you want to create a user with posts do you send back- in the body- an object that's prisma specific looking like this...
{
data: {
email: '<mailto:emma@prisma.io|emma@prisma.io>',
posts: {
create: [
{
title: 'My first post',
categories: {
connectOrCreate: [
{
create: { name: 'Introductions' },
where: {
name: 'Introductions',
},
},
],
},
},
{
title: 'How to make cookies',
categories: {
connectOrCreate: [
{
create: { name: 'Social' },
where: {
name: 'Social',
},
},
],
},
},
],
},
},
}
And just dump the prebuilt object into...
const { id } = await prisma.user.create({
data: req.body,
});
Or do you send back something less prisma specific like this...
data: {
email: '<mailto:emma@prisma.io|emma@prisma.io>',
posts:
[
{
title: 'My first post',
categories: [
{
name: 'Introductions',
},
],
},
{
title: 'How to make cookies',
categories:
[
{
name: 'Social',
},
],
},
],
},
And then build it up before passing it to the prisma.user.create
method?Jason Kleinberg
01/06/2022, 5:12 PMFranco Roura
01/06/2022, 5:49 PMJohn Smeeth
01/07/2022, 7:19 AMNecmettin Begiter
01/07/2022, 8:23 AMJiří Bartoš
01/07/2022, 9:42 AMSaim Akhtar
01/07/2022, 4:03 PMmodel Item {
id Int
itemName String @map("item_name")
variants Variants[]
}
model Variants {
id Int
unitPrice Decimal @map("unit_price")
item Item
}
NOW I want to sort items by minimum price of any of its variant
Is there a way I can achieve it via Prisma client, without using raw query to get my mapped fields in schema
P.S: Prisma doesn’t provide option of other fields for nested relation apart from _countChip Clark
01/07/2022, 4:46 PMmodel InvoiceTransaction {
InvoiceTransactionID Int @id @default(autoincrement())
CostCode String? @db.VarChar(40)
DisbursementAmount Decimal? @db.Decimal(20, 2)
InvoiceNumber String @db.VarChar(30)
InvoiceDate DateTime? @db.Date
InvoiceAmount Int
If the InvoiceAmount is changed to Decimal (like the DisbursementAmount) the number is returned as a string.
InvoiceTransactionID: 23765
CostCode: null
DisbursementAmount: "1260"
InvoiceAmount: 1260
InvoiceDate: "2020-07-06T00:00:00.000Z"
InvoiceNumber: "JUN.20 " "
How do I get the API to return the value as a decimal?Bram Adams
01/07/2022, 6:18 PMSebastian Rindom
01/08/2022, 11:31 AMmedusa migrations run
will ensure that all missing migrations from core + plugins are applied
Trying to map this to Prisma my thinking so far is this:
• Core + Plugins will have schema.prisma
• Core + Plugins will have migrations
• *Core will programmatically collect migrations and call Prisma Migrate
• *Core programatically creates a Prisma client that is unique to the user’s core + plugins combination
My questions are about the last two steps marked with * - 1) are these steps possible and recommended and 2) are there alternative approaches that would be betterOmkar Kulkarni
01/08/2022, 2:00 PMmodel Video {
id String @id @default(uuid())
reactions Reactions[]
}
model Reactions {
id String @id @default(uuid())
type ReactionType
user User? @relation(fields: [user_id], references: [id])
user_id String?
video Video? @relation(fields: [video_id], references: [id])
video_id String
}
enum ReactionType {
NICE
YIKES
KEKW
POGGERS
}
I want to query for a unique video and get count of reactions typewise
{
id: "some video uuid",
title:"My nice video",
reactions : {
nice : 44,
yikes : 2,
kekw : 41,
poggers : 3
}
}
any way to query thisVille
01/08/2022, 3:18 PMAstral Gaming
01/08/2022, 11:14 PM_count: {
select: {
posts: true
},
where: {
posts: {
deletedAt: {
equals: null
}
}
}
}
Awey
01/09/2022, 10:34 AMChris Bongers
01/09/2022, 11:41 AMnpx prisma migrate dev
I get the following:
[*] Changed the `photo` table
[+] Added foreign key on columns (userId)
? We need to reset the PostgreSQL database "test_db" at "localhost:5432".
Do you want to continue? All data will be lost.
How can I go about keeping my data whilst migrating to Prisma from TypeORM?
The TypeORM looks like this:
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;
@OneToMany((type) => Photo, (photo) => photo.user)
photos: Photo[];
}
@Entity()
export class Photo {
@PrimaryGeneratedColumn()
id: number;
@ManyToOne((type) => User, (user) => user.photos)
user: User;
}
Michael Reh
01/09/2022, 2:42 PMSlackbot
01/09/2022, 3:00 PMGaurav Mittal
01/09/2022, 3:11 PMsudo npm install
works fine
but sudo npm start
gives me this error:
> npx prisma generate && npx prisma migrate dev && ts-node-dev src/bot.ts
sh: 1: prisma: Permission denied
Unable to find anything about this on Google search. It ran smoothly on my local with the same commands.
node version: 16.6.1
npm version: 7.20.3
Any guidance would be greatly appreciated 🙏stevebarakat
01/09/2022, 6:50 PMdelete
an item from the db
and update
all the other items in one action
?
I'm trying to do this:
js
await db.task.delete({
where: {
id: taskToDeleteId,
},
});
for (let i = 0; i < fixedTasks.length; i++) {
db.task.update({
where: {
id: fixedTasks[i].id,
},
data: {
id: fixedTasks[i].id,
name: fixedTasks[i].name,
position: parseInt(fixedTasks[i].position),
isCompleted: fixedTasks[i].isCompleted,
},
});
}
I'm getting an error:
Error:
Invalid `db.task.delete()` invocation in
/Users/sb/Dev/my-remix-dnd/build/index.js:542:27
539 }
540 break;
541 case "delete":
→ 542 await db.task.delete(
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: ConnectionError(Timed out during query execution.) })
at cb (/Users/sb/Dev/my-remix-dnd/node_modules/@prisma/client/runtime/index.js:38692:17)
at async action (/Users/sb/Dev/my-remix-dnd/build/index.js:542:7)
at async Object.callRouteAction (/Users/sb/Dev/my-remix-dnd/node_modules/@remix-run/server-runtime/data.js:36:14)
at async handleDataRequest (/Users/sb/Dev/my-remix-dnd/node_modules/@remix-run/server-runtime/server.js:110:18)
at async requestHandler (/Users/sb/Dev/my-remix-dnd/node_modules/@remix-run/server-runtime/server.js:45:20)
at async /Users/sb/Dev/my-remix-dnd/node_modules/@remix-run/express/server.js:45:22
Thank you!Aman Tiwari
01/09/2022, 9:31 PMconst enquiry = await db.enquiry.findFirst({
where: { id },
include: {
users: {
include: {
user: true,
},
},
},
})
if (!enquiry) throw new NotFoundError()
const partner = enquiry.users.filter((arr) => arr.user.role === "PARTNER")[0]
const customer = enquiry.users.filter((arr) => arr.user.role === "USER")[0]
return { ...enquiry, partner, customer }
is this good idea? what are the other way to do?Eudes Tenório
01/09/2022, 11:00 PM