Evan Kolb
09/30/2021, 3:40 PMTorrino
09/30/2021, 4:38 PMrpg_inventory
found here https://stackoverflow.com/a/48054742 using Prisma?
The 3rd column references an ID of a different table but which table? well it depends on the 2nd column id (type_reference
) and I'm confused as to how to choose which prisma Model is being referenced?
Any help or someone I could exchange some thoughts with would be greatly appreciatedMoh
10/01/2021, 5:14 AMuser
10/01/2021, 10:35 AMhttps://www.youtube.com/watch?v=auckcBaZifw&list=PLn2e1F9Rfr6k6MwzS-p9FGK1NDBxxwLPk&index=13&pp=sAQB▾
https://www.youtube.com/watch?v=f1KxJi-2PFo&list=PLn2e1F9Rfr6k6MwzS-p9FGK1NDBxxwLPk&index=11&pp=sAQB▾
Cree Jee
10/01/2021, 12:47 PM//other
model LayoutSetting {
id Int @id @default(autoincrement())
relatedLayoutToProduct LayoutSettingLinkProduct[]
}
model LayoutSettingLinkProduct {
layoutId Int
productId Int
order Int
layout LayoutSetting @relation(fields: [layoutId], references: [id])
product Product @relation(fields: [productId], references: [id])
@@id([layoutId, productId])
@@index([order])
}
model Product {
id Int @id @default(autoincrement())
relatedLayoutToProduct LayoutSettingLinkProduct[]
}
After executing many transactions and queries as a batch program, the following errors occurred.
Invalid `prisma.layoutSettingLinkProduct.deleteMany()` invocation:
Failed to validate the query: `Field does not exist on enclosing type.` at `Mutation.deleteManyLayoutSettingLinkProduct`
at cb (/Users/creejee/*****/renewal-project/*********/node_modules/@*****************/appsync-schema/prisma/generated/client/runtime/index.js:36952:17)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async upsertLayout (/Users/creejee/*****/renewal-project/*********/util/batch/appsync/insertProductData.js:59:9)
at async task (/Users/creejee/*****/renewal-project/*********/util/batch/appsync/insertProductData.js:496:9) {
code: 'P2009',
clientVersion: '3.1.1',
meta: {
query_validation_error: 'Field does not exist on enclosing type.',
query_position: 'Mutation.deleteManyLayoutSettingLinkProduct'
}
}
The following sample code was written for problem trouble shooting, and there was no error at this time.
const layout = await prismaClient.layoutSetting.create({
data: {},
});
const product = await prismaClient.product.create({
data: {},
});
if (layout && product) {
await prismaClient.layoutSettingLinkProduct.createMany({
data: {
layoutId: layout.id,
productId: product.id,
order: 1,
},
});
const { count } =
await prismaClient.layoutSettingLinkProduct.deleteMany({
where: {
layoutId: layout.id,
},
});
console.log(count);
}
I don’t know what I need to solve the problem, and I don’t know why there’s no error in the sample code...
Is this a bug? Or is it my fault?Casey Chow
10/01/2021, 6:48 PMРоман Адигезалов
10/02/2021, 7:00 AMut dev
10/02/2021, 9:40 AMut dev
10/02/2021, 9:42 AM"message": "\nInvalid `prisma.link.findMany()` invocation:\n\n{\n take: null\n ~~~~\n}\n\n
Argument take must not be null. Please use undefined instead.\n\n",
I think it refers to this line in my graphql/resolvers.ts file
export const resolvers = {
Query: {
links: (_parent, _args, ctx) => {
return ctx.prisma.link.findMany()
},
},
}
ut dev
10/02/2021, 10:22 AMMax Hodges
10/02/2021, 10:28 AMINSERT INTO 'blackship$prod'.'WarehouseLocations' (name)
VALUES
('01-00-0-0'
'01-00-0-1', etc.)
but fails because
null value in column "id" violates not-null constraint
I see the id column is varchar, not an auto-number, so . . . what’s the method? do I gotta use javascript for this? 😞Chris V
10/02/2021, 10:34 AMyarn
for installing and building, whereas Elastic Beanstalk installs with npm
. I updated the CodeBuild step to also use npm
and things seem to be working 🤞 Still interesting to note that Prisma v2 worked fine the whole time.
I'm having trouble deploying Prisma to Elastic Beanstalk - I am able to deploy Prisma at version 2, but not at version 3.
When using prisma
and @prisma/client
at version 3, the Elastic Beanstalk npm --production install
command fails but with no obvious error message - I will leave the full logs as a reply to this message.
Any ideas what might cause this? As I say, if I downgrade to version 2 then the deployment works fine. I have also tried running npm --production install
locally with the same version of Node used in the EB build, and it also works fine.oliver
10/02/2021, 11:27 AMMartin Klasson
10/02/2021, 5:40 PMawait prisma.discLibrary.findMany({????})
I want to get all rows in discLibrary. but I also want the row from corresponding row in "DiscManufacturer"-model.
How come it feels like it is tough? When it should be easyl The documentation does not help me out ;/Martin Klasson
10/02/2021, 5:41 PMMartin Klasson
10/02/2021, 5:46 PMDanny
10/02/2021, 8:23 PMts-node prisma/seed.ts
as recommended in the guide (currently seed.ts just has some console.logs for testing) and I have all the necessary dev dependencies installed.
When I run prisma db seed
I get the following:
Environment variables loaded from .env
Running seed command `ts-node ./prisma/seed.ts` ...
An error occured while running the seed command:
Error: Command failed with ENOENT: ts-node ./prisma/seed.ts
spawn ts-node ENOENT
Trying to run the script manually with ts-node with npx ts-node ./prisma/seed.ts
I get the following:
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /workspace/prisma/seed.ts
at new NodeError (node:internal/errors:371:5)
at Loader.defaultGetFormat [as _getFormat] (node:internal/modules/esm/get_format:71:15)
at Loader.getFormat (node:internal/modules/esm/loader:105:42)
at Loader.getModuleJob (node:internal/modules/esm/loader:243:31)
at async Loader.import (node:internal/modules/esm/loader:177:17)
at async Object.loadESM (node:internal/process/esm_loader:68:5)
at async handleMainPromise (node:internal/modules/run_main:63:12) {
code: 'ERR_UNKNOWN_FILE_EXTENSION'
}
Has anybody run into this and know what's the best way to handle this from Prisma's end and found an elegant solution? This seems related to a big mess with ts-node when it comes to ESM support, ([1], [2], etc.) and the only way I've been able to get seed.ts to execute has been to remove type: "module"
from my package.json. ts-node's docs recommend using an experimental Node.js API for using ts-node as a loader, but that's literally scheduled to break soon with node 16.10 and likely again in the future. I was also hopeful module type overrides would help, but it doesn't seem to do anything for executing seed.ts without these errors.
My current workaround is to compile seed.ts with tsc, execute it with node, then clean up the js file. Since the prisma.seed command only takes one command and isn't bash-like, I create a package.json script with tsc prisma/seed.ts && node prisma/seed.js && rm prisma/seed.js
and then make that my prisma.seed script "seed": "npm run seed-db"
. This seems kind of clunky and I don't like that I have to write and clean up a transient file.user
10/02/2021, 10:50 PMFaisal Sayed
10/03/2021, 12:48 PM2021-10-03T12:47:13.217Z 1e02a299-de4d-4526-9a0c-6238a389ee61 ERROR ReferenceError: prisma is not defined
at Object.5324 (/var/task/.next/server/pages/api/auth/[...nextauth].js:23:10)
at __webpack_require__ (/var/task/.next/server/webpack-runtime.js:25:43)
at Module.1529 (/var/task/.next/server/pages/api/auth/[...nextauth].js:51:14)
at __webpack_require__ (/var/task/.next/server/webpack-runtime.js:25:43)
at __webpack_exec__ (/var/task/.next/server/pages/api/auth/[...nextauth].js:91:39)
at /var/task/.next/server/pages/api/auth/[...nextauth].js:92:28
at Object.<anonymous> (/var/task/.next/server/pages/api/auth/[...nextauth].js:95:3)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
RequestId: 1e02a299-de4d-4526-9a0c-6238a389ee61 Error: Runtime exited with error: exit status 1
Runtime.ExitError
MichaelHindley
10/03/2021, 7:05 PMprisma
folder and tries to take both the schema.prisma/.env
files from the deeply nested assets bundles from the infrastructure deployment outputs. Which does not even exist in those locations!
Prisma is trying to load this path, which does not exist:
/Users/hindley/Documents/project/aws/cdk.out/asset.352d16b78797811d23876d149c74340d4b5ae90245ec70aee0bc6d643d46fd1d/prisma/.env
There is however a directory that looks somewhat like that but not quite:
/Users/hindley/Documents/project/aws/cdk.out/asset.352d16b78797811d23876d149c74340d4b5ae90245ec70aee0bc6d643d46fd1d/node_modules/.prisma/
I don’t even know how it’s finding the paths, not only that, the prisma determined location is missing the files it’s trying to load.
The aws
folder is excluded from tsconfig, is built separately and it’s also it’s own package with it’s own dependencies. There is nothing imported from there from the root-level entrypoint, this is triggered by simply importing the prisma client from any root-level file.
I found this out by setting a breakpoint in https://github.com/prisma/prisma/blob/ba74c81fdbc9e6405946fdc6f9d42d103d008dc2/packages/client/src/runtime/getPrismaClient.ts#L300. envPath.schemaEnvPath is pointing to the alphabetically sorted most recent asset build. I suspect prisma is doing some deep tree traversal to find schema.prisma/.env files instead of checking things in the order that docs link below state.
This is not consistent with the docs at https://www.prisma.io/docs/guides/development-environment/environment-variables#env-file-locations. It should load the prisma/.env
files and though not specific, I would understand that the prisma/schema.prisma
file should be used too, and not the first one encountered in deeply nested directories.
Here is a basic repo: https://github.com/MichaelHindley/prisma-env-dbguser
10/04/2021, 7:54 AMhttps://www.youtube.com/watch?v=NaxQXClnYSE&list=PLn2e1F9Rfr6k6MwzS-p9FGK1NDBxxwLPk&index=18&pp=sAQB▾
Donte
10/04/2021, 8:58 AMConst {user} = ctx.Prisma.user.findMany({
where:{
resetToken: args.resetToken,
resetTokenExpiry:???
}
})
Is there another way to check for resetTokenExpiry?
Thanks 😊Moh
10/04/2021, 9:32 AMawait prisma.treatment.create({
data: {
name: "Treatment A",
clinic: { connect: { id: "SOME ID" }},
metadata: { create: { infos: "JSON" }},
treatment_city: {
createMany: {
data: cityIds.map(cityId => ({
city_id: cityId,
metadata_id: <Id from above>, (??)
treatment_id: <id of created treatment>, (??)
}))
}
}
}
})
Francesco Bruno
10/04/2021, 9:34 AMprisma generate
and can use the prisma client, typing <http://prisma.XXX|prisma.XXX>
suggests my model names correctly, however prisma.MODEL
contains no typings.
Any idea on how i could troubleshoot this?Jonathan
10/04/2021, 9:49 AMdo4gr
Phil Bookst
10/04/2021, 10:49 AMmodel Profile {
id String? @unique
username String @id
profile_pic_url String?
follower Int?
following Int?
images Image[]
@@map("profile")
}
model Location {
id String @unique
name String @id
images Image[]
@@map("location")
}
model Hashtag {
id String? @unique
name String @id
images Image[]
@@map("hashtag")
}
model Image {
id String @id
thumbnail String
shortcode String @unique
like_count Int
comment_count Int
profile Profile? @relation(fields: [profileUsername], references: [username])
profileUsername String?
hashtag Hashtag? @relation(fields: [hashtagName], references: [name])
hashtagName String?
location Location? @relation(fields: [locationId], references: [id])
locationId String?
// Is this ok?
@@index([id, profileUsername])
@@index([id, hashtagName])
@@index([id, locationId])
//
@@map("image")
}
Hey guys, quick question - is it ok to set indexes on my relations? I've experienced slow reads but since I added the indexes above the speed has increased a lot!
Is this safe to do or will it cause problems in the future when the tables get bigger?user
10/04/2021, 11:41 AMLarry Mickie
10/04/2021, 12:55 PM