Bård
06/29/2021, 9:46 AMprisma.practitioneer.update({
where: {
userID,
},
data: {
image: {
update: {
where: { id: imageID },
data: {
image: image.data,
type: image.type,
},
},
},
},
});
But I’m getting this error:
Unknown arg `image` in data.image for type practitioneerUncheckedUpdateInput. Did you mean `imageID`? Available args: …
If I try to change the query to (which is obviously wrong):
prisma.practitioneer.update({
where: {
userID,
},
data: {
imageID: {
update: {
where: { id: imageID },
data: {
image: image.data,
type: image.type,
},
},
},
},
});
I get the same error, only now it’s suggesting the correct field, the one it previously said it didn’t find:
Unknown arg `imageID` in data.image for type practitioneerUncheckedUpdateInput. Did you mean `image`? Available args: …
user
06/29/2021, 10:06 AMRichard Dunn
06/29/2021, 11:06 AMDev__
06/29/2021, 1:42 PMmodel User {
....
memos Memo[]
}
model Memo {
userId String?
user User? @relation(fields: [userId], references: [id])
}
Dev__
06/29/2021, 2:58 PMP2014
and now on 2.26 I get P2003
. Is this change related to the new update with referentialActions
?Dick Fickling
06/29/2021, 3:51 PMfoobar1
?Pablo Sáez
06/29/2021, 5:32 PMMichael Grigoryan
06/29/2021, 8:36 PMimport faker from "faker";
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
export async function seed() {
const user = await prisma.user.create({
data: {
lastName: faker.name.lastName(),
firstName: faker.name.firstName(),
},
});
const post = await prisma.post.create({
data: {
userId: user.id,
body: faker.lorem.slug(300),
},
});
console.log({ post, user });
}
The information is not being logged and is not being saved to the database... Is there something wrong or am I doing something not correctly?Awey
06/29/2021, 10:04 PMAntoin Campbell
06/29/2021, 11:25 PMnpx prisma migrate deploy
I get this error:
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "postgres", schema "public" at "IP"
Error: P1001: Can't reach database server at `IP`:`5432`
Please make sure your database server is running at `IP`:`5432`.
Error: Process completed with exit code 1.
Antoin Campbell
06/29/2021, 11:28 PMprisma chobo
06/30/2021, 12:45 AMmodel User {
id String @id @default(cuid())
password String? @db.VarChar(255)
phoneNumber String @unique
createdAt DateTime?
updatedAt DateTime?
deletedAt DateTime?
}
and when I do this:
await prisma.user.create({
data: {
password: "password",
phoneNumber: "+4081824712",
},
});
I get this error:
Invalid `prisma.user.create()` invocation:
{
data: {
createdAt: '2021-06-30T00:41:32Z',
+ phoneNumber: String,
? id?: String,
? password?: String | null,
? updatedAt?: DateTime | null,
? deletedAt?: DateTime | null
}
}
Argument phoneNumber for data.phoneNumber is missing.
Note: Lines with + are required, lines with ? are optional.
prisma chobo
06/30/2021, 12:45 AMprisma chobo
06/30/2021, 12:46 AMSean Doughty
06/30/2021, 4:11 AMmodel Circle {
id Int @id @default(autoincrement())
name String
shape Shape?
}
model Square {
id Int @id @default(autoincrement())
name String
shape Shape?
}
model Shape {
id Int @id @default(autoincrement())
type String
typeId Int
circle Circle? @relation(fields: [typeId], references: [id])
square Square? @relation(fields: [typeId], references: [id])
}
I think what I am looking for is "optional" relationArun Kumar
06/30/2021, 7:05 AMcreate
option in upsert
update if there is an existing record?Arun Kumar
06/30/2021, 7:08 AMcreate
and update
Nima
06/30/2021, 7:12 AMreferentialActions
breaks current Studio release 😞
https://github.com/prisma/studio/issues/716
Error starting Prisma Client: {
"message": "Schema Parsing P1012\n\nGet config \nerror: The preview feature \"referentialActions\" is not known. Expected one of: microsoftSqlServer, orderByRelation, nApi, selectRelationCount, orderByAggregateGroup, filterJson\n --> schema.prisma:9\n | \n 8 | provider = \"prisma-client-js\"\n 9 | previewFeatures = [\"orderByRelation\", \"nApi\", \"referentialActions\"]\n | \n\nValidation Error Count: 1\n",
Nima
06/30/2021, 8:19 AMBård
06/30/2021, 8:41 AMimport { PrismaClient } from '@prisma/client';
// add prisma to the NodeJS global type
interface CustomNodeJsGlobal extends NodeJS.Global {
prisma: PrismaClient;
}
// Prevent multiple instances of Prisma Client in development
declare const global: CustomNodeJsGlobal;
const prisma = global.prisma || new PrismaClient();
if (process.env.NODE_ENV === 'development') global.prisma = prisma;
export default prisma;
Is there any best practice way of including a Prisma middleware in a NextJS app? The docs only mentions an express app.Aman Tiwari
06/30/2021, 8:51 AMaqib
06/30/2021, 10:34 AMaqib
06/30/2021, 10:34 AMMutation: {
...buildMutationResolvers(prisma.mutation),
},
Subscription: {
submission: {
subscribe: () => pubsub.asyncIterator(['SUBMISSION_CREATED', 'SUBMISSION_UPDATED', 'SUBMISSION_DELETED'])
},
submissionReview: {
subscribe: () => pubsub.asyncIterator(['WAR_CREATED', 'WAR_UPDATED', 'WAR_DELETED'])
}
},
aqib
06/30/2021, 10:35 AMconst buildMutationResolvers = (methods) =>
Object.entries(methods).reduce(
(resolvers, [queryName, queryFunc]) => ({
...resolvers,
[queryName]: async (parent, args, context, info) => {
const label = getPublishLabel(queryName)
// const data = await queryFunc(args, info)
if(label) {
pubsub.publish(label[0], { [label[1]]: args});
}
return queryFunc(args, info)
},
}),
{}
);
aqib
06/30/2021, 10:36 AMconst getPublishLabel = (mutationName) => {
const labels = {
createSubmission: ['SUBMISSION_CREATED', 'submission'],
updateSubmission: ['SUBMISSION_UPDATED', 'submission'],
deleteSubmission: ['SUBMISSION_DELETED', 'submission'],
}
if(!!labels[mutationName]) return labels[mutationName]
return false
}
aqib
06/30/2021, 10:36 AMEdmir Suljic
06/30/2021, 10:42 AMconst device = await prisma.device.findUnique({
where: {
deviceType: {
contains: args.data.deviceType
}
},
connect: {
user: {
id: userId
}
}
});
This obviously doesnt work but hopefully you would get the idea.Nimish Gupta
06/30/2021, 11:27 AMPostgres
as DB)
model Test {
id String @id @default(uuid())
name String
// common fields
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
@@map("test")
}
and using below code snippet in node js.
async function update() {
// Node js
// Current state of the row in the DB
await model.test.findUnique({ where: { id: 1 } });
// { id: 1, name: "current_value", updated_at: "2021-06-30T11:00:16.291Z", created_at: "2021-06-30T11:00:16.291Z"}
await model.test.updateMany({ data: { name: "after_update" } });
// { id: 1, name: "after_update", updated_at: "2021-06-30T12:00:16.291Z", created_at: "2021-06-30T11:00:16.291Z"}
await model.$queryRaw(`UPDATE test set name = 'updater_after_raw'`); // @rawQuery
// { id: 1, name: "updater_after_raw", updated_at: "2021-06-30T12:00:16.291Z", created_at: "2021-06-30T11:00:16.291Z"}
}
Here after @rawQuery
, update_at
field is not being updated. Couldn't understand this behaviour. Is this intentional or any issue?
Expected behaviour - It should update the updated_at
field when I am writing raw update query in prisma.stephan levi
06/30/2021, 12:06 PMBård
06/30/2021, 12:46 PMprisma.user.create({
someRelationalField: {
connect: {
userId: userID
},
update: {
// Is this possible?
}
}
})