Dan
10/21/2021, 12:22 AMupdateMany
not allow skip
and take
?Dan
10/21/2021, 12:27 AMEthan Zoller
10/21/2021, 4:18 AMEthan Zoller
10/21/2021, 4:19 AMLars Ivar Igesund
10/21/2021, 8:10 AMYaakov
10/21/2021, 11:53 AM- id
- name
services
- id
- name
areas
- id
- name
vendors_services_areas
- vendor_id
- service_id
- area_id
@@id([vendor_id, service_id, area_id])
How can this be defined in Prisma Schema and how do I add a new vendor mapped to its two relationships?user
10/21/2021, 12:51 PMprisma init
07:34 - writing the Prisma schema
11:29 - set up a PostgreSQL database using cloud.prisma.io/postgres.app
16:44 - creating a migration
19:21 - seeding the database
26:00 - question: are Prisma and GraphQL related? + live debugging + recap
29:20 - initializing Prisma Client in a Next.js app
31:21 - creating API endpoint for submitting feedback
36:08 - sending requests to the create endpoint
from the frontend
42:00 - displaying the list of feedback
45:49 - Next.js getServerSideProps serializing problem
47:25 - Recap, Conclusion, and questionsNic Luciano
10/21/2021, 12:59 PMnode_modules
.
i am having 2 strange issues. any help with either one would be amazing, i suspect they are related.
i apologize for the wall of text, it's mostly debug output!!!
a quick tour of the monorepo:
rpphub/node_modules/@prisma
rpphub/package.json
db workspace source (the prisma project):
rpphub/workspaces/db/package.json
rpphub/workspaces/db/schema.prisma
rpphub/workspaces/db/migrations/*
rpphub/workspaces/db/lib (client output goes here)
rpphub/workspaces/db/lib/index.js
rpphub/workspaces/db/lib/schema.prisma
rpphub/workspaces/db/lib/[...the rest of the generated files..]
and finally a nextjs app trying to utilize prisma client:
rpphub/workspaces/web
furthermore, my rpphub/workspaces/db/package.json
contains inclusion directives:
"main": "lib/index.js",
"browser": "lib/index-browser.js",
"types": "lib/index.d.ts"
***issue 1***:
the client does not work from the node REPL for certain working directories.
if i am in the rpphub/workspaces/db
directory i can have the following session:
$:~/Code/rpphub/workspaces/db$ node
Welcome to Node.js v14.15.4.
Type ".help" for more information.
> const plib = require('.')
undefined
> const client = new plib.PrismaClient()
undefined
but if i am in the rpphub
directory, a similar session fails:
$:~/Code/rpphub$ node
Welcome to Node.js v14.15.4.
Type ".help" for more information.
> const plib = require('./workspaces/db')
undefined
> const client = new plib.PrismaClient()
Uncaught:
Error: ENOENT: no such file or directory, open '/home/nic/Code/rpphub/.git/schema.prisma'
at Object.openSync (fs.js:476:3)
at Object.readFileSync (fs.js:377:35)
at new LibraryEngine (/home/nic/Code/rpphub/workspaces/db/lib/runtime/index.js:36078:40)
at PrismaClient.getEngine (/home/nic/Code/rpphub/workspaces/db/lib/runtime/index.js:39108:16)
at new PrismaClient (/home/nic/Code/rpphub/workspaces/db/lib/runtime/index.js:39079:29) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/home/nic/Code/rpphub/.git/schema.prisma',
clientVersion: '3.3.0'
}
***issue 2***:
the code fails runtime when being included in my Nextjs project in rpphub/workspaces/web
. at runtime, import * as PrismaClient from "@rpphub/db";
results in
error - Error: Cannot find module 'os'
at webpackEmptyContext (/home/nic/Code/rpphub/workspaces/web/.next/server/pages/api/test.js:53:10)
at ../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js (webpack-internal:///../db/lib/runtime/index.js:1738:15)
at __require2 (webpack-internal:///../db/lib/runtime/index.js:87:45)
at ../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js (webpack-internal:///../db/lib/runtime/index.js:2002:56)
at __require2 (webpack-internal:///../db/lib/runtime/index.js:87:45)
at eval (webpack-internal:///../db/lib/runtime/index.js:30776:33)
at Object.../db/lib/runtime/index.js (/home/nic/Code/rpphub/workspaces/web/.next/server/pages/api/test.js:42:1)
at __webpack_require__ (/home/nic/Code/rpphub/workspaces/web/.next/server/webpack-runtime.js:33:42)
at eval (webpack-internal:///../db/lib/index.js:17:5)
at Object.../db/lib/index.js (/home/nic/Code/rpphub/workspaces/web/.next/server/pages/api/test.js:32:1) {
code: 'MODULE_NOT_FOUND'
which you can see stems from var os2 = __require("os");
in rpphub/workspaces/db/lib/runtime/index.js.
. i recognize this could definitely be more of a next-question than a prisma question, if that's the case i apologize! i thought next might require further module transpilation but i had no luck going that route.
thank you all!David Sooter
10/21/2021, 3:59 PMLeo Li
10/21/2021, 4:29 PMNoel Martin Llevares
10/21/2021, 5:22 PMBruno Casado
10/21/2021, 5:58 PMTableA {
fieldA_id int
fieldA Gene @relation(fields: [fieldA_id], references: [id])
}
Gene {
...
TableA TableA[]
}
But after i changed the Gene TableA to use 2 fields but same opposition relationship it stops to works:
like:
fieldA_id int
fieldB_id int
fieldA Gene @relation(name: "field_a_pk", fields: [fieldA_id], references: [id])
fieldB Gene @relation(name: "field_b_pk", fields: [fieldB_id], references: [id])
error:
WomanCareInfo = TableA in this case.
error: Error validating field `gene_loc_1` in model `WomanCareInfo`: The relation field `gene_loc_1` on Model `WomanCareInfo` is missing an opposite relation field on the model `Gene`. Either run `prisma format` or add it manually.
--> schema.prisma:335
|
334 |
335 | gene_loc_1 Gene @relation(name: "gene_1_pk", fields: [gene_1_id], references: [id])
336 | gene_loc_2 Gene @relation(name: "gene_2_pk", fields: [gene_2_id], references: [id])
|
error: Error validating field `gene_loc_2` in model `WomanCareInfo`: The relation field `gene_loc_2` on Model `WomanCareInfo` is missing an opposite relation field on the model `Gene`. Either run `prisma format` or add it manually.
--> schema.prisma:336
|
335 | gene_loc_1 Gene @relation(name: "gene_1_pk", fields: [gene_1_id], references: [id])
336 | gene_loc_2 Gene @relation(name: "gene_2_pk", fields: [gene_2_id], references: [id])
337 |
is this a sort of bug?Michael Aubry
10/21/2021, 6:24 PMTom MacWright
10/21/2021, 7:42 PMGabe O'Leary
10/21/2021, 7:44 PMThe migration `...` failed.
? We need to reset the PostgreSQL database "..." at "...".
Do you want to continue? All data will be lost. » (y/N)
also if I try to query the table on which the migration was attempted it runs for minutes without returning anything...
Seems like I've corrupted my DB.
Luckily I don't care that much about this data, but I would like to know what likely went wrong so I can avoid it in the future.
This table does have a JSON column with a potentially sizeable amount of data....is that what might've resulted in the migration command taking so long?
Also I had datagrip connected to the db when I triggered the migrate...is this an issue?Tom MacWright
10/21/2021, 8:20 PMdeleted
column in posts and only want to count the non-deleted posts? https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#include-a-_count-of-relationsTom MacWright
10/21/2021, 8:26 PMNoel Martin Llevares
10/21/2021, 11:58 PMNoel Martin Llevares
10/21/2021, 11:58 PMNoel Martin Llevares
10/21/2021, 11:59 PMNoel Martin Llevares
10/21/2021, 11:59 PMNoel Martin Llevares
10/22/2021, 12:00 AMNoel Martin Llevares
10/22/2021, 12:06 AMAhmed Khan
10/22/2021, 5:41 AMprisma.purchaseBill
api and not using a raw query. I read somewhere that we can't compare two column values in prisma as of now ?henry
10/22/2021, 5:50 AMuser
10/22/2021, 7:03 AMAlbin Groen
10/22/2021, 7:09 AMJemin Kothari
10/22/2021, 7:29 AMList
and Activity
model List {
id Int @id @default(autoincrement())
Activity Activity[]
@@map("list")
}
model Activity {
id Int @id @default(autoincrement())
status String
list_id Int
List List @relation(fields: [list_id], references: [ID])
@@map("activity")
}
Bård
10/22/2021, 9:14 AMmodel Questionnaire {
id Int @id @default(autoincrement())
title String
description String
maxLength Int?
validationType String
media Json
sequence Int @unique
userQuestions UserQuestions[]
}
model UserQuestions {
id Int @id @default(autoincrement())
answer String?
uid String
questionnaireId Int?
user User @relation(fields: [uid], references: [id])
questionnaire Questionnaire? @relation(fields: [questionnaireId], references: [id])
}
I'm trying to createMany UserQuestions entries. But when I try to connect them to the Questionnaire it doesn't recognize "questionnaire" on the UserQuestions model.
Code:
prisma.userQuestions.createMany({
data: [
{
uid,
questionnaire: {
connect: {
sequence: 1,
},
},
},
{
uid,
questionnaire: {
connect: {
sequence: 2,
},
},
},
{
uid,
questionnaire: {
connect: {
sequence: 3,
},
},
},
],
});
Error:
Unknown arg `questionnaire` in data.0.questionnaire for type UserQuestionsCreateManyInput. Did you mean `questionnaireId`? Available args:
type UserQuestionsCreateManyInput {
id?: Int
answer?: String | Null
uid: String
questionnaireId?: Int | Null
}
Bojan Šernek
10/22/2021, 9:49 AM