abdoaligomaa107
10/10/2022, 3:48 PMBryon Mapes
10/10/2022, 4:28 PMlawjolla
10/10/2022, 4:40 PMSebastian Gug
10/10/2022, 7:06 PM@prisma/client did not initialize yet. Please run "prisma generate" and try to import it again
in production -- my process is to run npx prisma generate
before building the project in the pipeline and then have this step in the docker container:
COPY ./node_modules/@prisma/client ./node_modules/@prisma/client
Are there extra steps required? it's a bit of an odd one. If I run these two commands:
RUN ls
RUN cd ./node_modules/@prisma/client && ls
right after, the result is:Sebastian Gug
10/10/2022, 7:08 PMSebastian Gug
10/10/2022, 7:16 PMCharlie
10/10/2022, 9:03 PMJustin Wenning
10/10/2022, 9:30 PMnpm i
in my postinstall
script on a t4g micro EC2 instance in my AWS EB environment. I can npm i
off a freshly-cloned repo on my local machine without issue. What am I doing wrong here?
> app@0.1.0 postinstall
> prisma migrate deploy
node:internal/fs/utils:345
throw err;
^
Error: ENOENT: no such file or directory, open '/var/app/current/node_modules/.bin/prisma_fmt_build_bg.wasm'
at Object.openSync (node:fs:585:3)
at Object.readFileSync (node:fs:453:35)
at ../../node_modules/.pnpm/@prisma+prisma-fmt-wasm@4.4.0-66.f352a33b70356f46311da8b00d83386dd9f145d6/node_modules/@prisma/prisma-fmt-wasm/src/prisma_fmt_build.js (/var/app/current/node_modules/.bin/prisma:12337:31)
at __require (/var/app/current/node_modules/.bin/prisma:14:50)
at Object.<anonymous> (/var/app/current/node_modules/.bin/prisma:86202:38)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/var/app/current/node_modules/.bin/prisma_fmt_build_bg.wasm'
}
npm ERR! code 1
npm ERR! path /var/app/current
npm ERR! command failed
npm ERR! command sh -c prisma migrate deploy
npm ERR! A complete log of this run can be found in:
npm ERR! /home/webapp/.npm/_logs/2022-10-10T21_19_49_623Z-debug-0.log
Amgelo563
10/11/2022, 1:34 AMcreate
data when using createMany
like when I do with create()
? I want to create (and connect) 1 entry for many entries I'm creating at the same time.
My use case is a Ticket service where I want to specify TicketAnswers the user answers when creating the ticket; the answers are connected through a one to many connection with Ticket, so I can't create the ticket first, I need to create the answers. So I'm trying to create them using prisma.answers.createMany()
and specifying ticket
like on create
(.create({ data: { answerData, ticket: { create: { ticketData } } } })
), but I'm not sure how I would do that. Looking at Prisma's index.d.ts doesn't help much since TicketAnswerCreateManyInput
doesn't seem to have that property.
Edit: Using a single .create()
with the specified create property and then using that for createMany as a workaround for now; would still like to know if there's a feature I missed or how I could achieve the same on a "cleaner" wayDIlpazir Ahmad
10/11/2022, 4:22 AMDIlpazir Ahmad
10/11/2022, 10:55 AMRan Rosenmann
10/11/2022, 3:08 PMRan Rosenmann
10/11/2022, 3:10 PMAlex Vilchis
10/11/2022, 7:30 PMHusnain Saeed
10/11/2022, 8:25 PMlike
prisma.beds.findMany({
where: {
House:{
RepairRecords:{
Equipment: {
None: { id: <self'id> }
}
}
}
}
})
Austin
10/11/2022, 8:26 PMschema.prisma
file?Husnain Saeed
10/11/2022, 8:52 PMwhere: {
House: {
Records: {
some: {
<check if latest>
Andres
10/12/2022, 1:04 AMtitle
which is a String and I'm migrating it to be of an "enum" type, nullable. So I updated the schema and run the migrate dev
command, but it failed because I had some existing values of title
that didn't match the allowed values of the enum, one of which was the empty string ''
. I edited the migration file to convert all ''
to NULL
but somehow this update statement is not working, it does nothing. If I ran it manually in my DB, it works impeccably. Here's my migration file:
UPDATE `PersonDetail` SET `title` = 'corporate admin' WHERE `title` = 'admin'; -- <=== UPDATE STATEMENT WORKS
UPDATE `PersonDetail` SET `title` = 'corporate editor' WHERE `title` = 'editor'; -- <=== UPDATE STATEMENT WORKS
-- THIS UPDATE STATEMENT DOES NOTHING, BUT WHEN RAN MANUALLY IN DB, IT WORKS
-- tried using TRIM(...) and ' ', ' ' and every suggestion here: <https://stackoverflow.com/questions/8470813/how-do-i-check-if-a-column-is-empty-or-null-in-mysql>
-- nothing worked so far
UPDATE `PersonDetail` SET `title` = NULL WHERE `title` = '';
-- AlterTable
ALTER TABLE `PersonDetail` MODIFY `title` ENUM('private investor', 'geologist', 'engineer', 'fund manager', 'analyst', 'other', 'broker', 'metallurgist', 'esg specialist', 'corporate admin', 'corporate editor') NULL;
Arpan Bagui
10/12/2022, 7:12 AMDonald Dewulf
10/12/2022, 10:57 AMEvangelos Charalampidis
10/12/2022, 3:57 PMawait prisma.comment.update({
where: {
id: id,
},
data: {
likes: likes,
},
});
does the update call alter both the updatedAt and the createdAt entries? It should not, right? @NurulHassan Anwar
10/12/2022, 4:10 PMupdate, err1 := h.client.Projects.FindUnique(
db.Projects.ProjectGUID.Equals(project.ProjectGUID),
).Update(
db.Projects.Title.Set(project.Title),
db.Projects.Description.Set(project.Description),
).Exec(context.Background())
and My DB:
model Users {
Id Int @id @default(autoincrement())
Guid String @unique
Email String @unique
Name String
Password String
Role Role @default(USER)
SecretKey String @default("")
IsDeleted Boolean @default(false)
DateCreated DateTime @default(now())
Projects Projects[]
}
model Projects{
Id Int @id @default(autoincrement())
ProjectGuid String @unique
UserGuid String
Title String
Link String?
Description String
Users Users @relation(fields:[UserGuid], references:[Guid])
}
Hassan Anwar
10/12/2022, 4:11 PMHassan Anwar
10/12/2022, 4:12 PMJakob Clausen
10/12/2022, 5:06 PMmodel User {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
name String
email String @unique
projects UsersInProjects[]
@@map("user")
}
model Project {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
name String
customer String
users UsersInProjects[]
@@map("project")
}
model UsersInProjects {
id Int @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId Int @map("user_id")
project Project @relation(fields: [projectId], references: [id])
projectId Int @map("project_id")
@@id([userId, projectId])
@@map("users_in_projects")
}
And my typeDefs types looks like this =>
type User {
id: Int!
createdAt: DateTime!
updatedAt: DateTime!
name: String!
email: String!
projects: [Project]
}
type Project {
id: Int!
createdAt: DateTime!
updatedAt: DateTime!
name: String!
customer: String!
users: [User]
}
This is my query =>
context.prisma.user.findMany({
skip: args.offset ?? 0,
take: args.limit ?? 10,
include: {
projects: true,
},
});
I get error from this. It says that name does not exit. So it tries to get fields from UsersInProjects. But want to be able to fetch users on projects and vice versa. Any ideas?benjick
10/12/2022, 5:16 PMmodel Integration {
id String @id @default(auto()) @map("_id") @db.ObjectId
type String
settings Json
owner User @relation(fields: [ownerId], references: [id])
ownerId String @db.ObjectId
}
How come I can't run the following?
prisma.integration.delete({
where: {
id: input.id,
ownerId: ctx.session!.user!.id,
},
});
Giving me this error: Object literal may only specify known properties, and 'ownerId' does not exist in type 'IntegrationWhereUniqueInput'.
Moonchild Everlasting
10/12/2022, 5:32 PMMoonchild Everlasting
10/12/2022, 5:33 PMRobert Lee
10/12/2022, 5:39 PMmodel Taggable {
tags String[]
}
How would I go about finding the distinct set of tags in Taggable? Group by seems to be looking at the list as an immutable array rather than considering each element in the tags array:
const tags = await prisma.taggable.groupBy({
by: ["tags"],
_count: {
tags: true,
},
orderBy: {
_count: {
tags: "desc",
},
},
});
Returns something like:
[
{
"_count": {
"tags": 1
},
"tags": ["Tag #1"]
},
{
"_count": {
"tags": 1
},
"tags": [ "Tag #1", "Tag #2"]
}
]
Where I want something like
[
{
"_count": {
"tags": 2
},
"tag": "Tag #1"
},
{
"_count": {
"tags": 1
},
"tag": "Tag #2"
}
]
Any ideas?Moonchild Everlasting
10/12/2022, 5:40 PM