Jordansz
10/15/2022, 8:47 PMJordansz
10/15/2022, 8:48 PMmodel User {
id String @id @default(cuid())
email String @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
password Password?
notes Note[]
}
model Password {
hash String
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
userId String @unique
}
Jordansz
10/15/2022, 8:48 PMDave Edelhart
10/15/2022, 9:27 PMphone String @default("");
why not?TomΓ‘Ε‘
10/16/2022, 12:17 PMconst sql = Prisma.sql`INSERT INTO "vendor" (id, name, description, "userId", alias, emails, phones, address, links, location) VALUES (${id}, ${
data.name
}, ${data.description}, ${
userId ?? "A0605996-E265-47DF-B152-179C298BB2BC"
}, ${slugify(`${data.name}_${id.slice(0, 4)}`, "_")}, ${data.emails}, ${
data.phones
}, ${data.address}, ${data.links}, ${null});`;
Bart Westenenk
10/16/2022, 1:14 PMBart Westenenk
10/16/2022, 1:14 PMBart Westenenk
10/16/2022, 3:13 PMmazhar iqbal
10/16/2022, 4:32 PMNeil Girardi
10/17/2022, 1:02 AM[next-auth][error][adapter_error_getSessionAndUser]
<https://next-auth.js.org/errors#adapter_error_getsessionanduser>
Invalid `p.session.findUnique()` invocation in
/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@next-auth/prisma-adapter/dist/index.js:22:52
19 linkAccount: (data) => p.account.create({ data }),
20 unlinkAccount: (provider_providerAccountId) => p.account.delete({ where: { provider_providerAccountId } }),
21 async getSessionAndUser(sessionToken) {
β 22 const userAndSession = await p.session.findUnique(
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E26000), message: "prepared statement \"s56\" does not exist", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("prepare.c"), line: Some(485), routine: Some("FetchPreparedStatement") }) }) }) {
message: '\n' +
'Invalid `p.session.findUnique()` invocation in\n' +
'/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@next-auth/prisma-adapter/dist/index.js:22:52\n' +
'\n' +
' 19 linkAccount: (data) => p.account.create({ data }),\n' +
' 20 unlinkAccount: (provider_providerAccountId) => p.account.delete({ where: { provider_providerAccountId } }),\n' +
' 21 async getSessionAndUser(sessionToken) {\n' +
'β 22 const userAndSession = await p.session.findUnique(\n' +
'Error occurred during query execution:\n' +
'ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E26000), message: "prepared statement \\"s56\\" does not exist", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("prepare.c"), line: Some(485), routine: Some("FetchPreparedStatement") }) }) })',
stack: 'Error: \n' +
'Invalid `p.session.findUnique()` invocation in\n' +
'/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@next-auth/prisma-adapter/dist/index.js:22:52\n' +
'\n' +
' 19 linkAccount: (data) => p.account.create({ data }),\n' +
' 20 unlinkAccount: (provider_providerAccountId) => p.account.delete({ where: { provider_providerAccountId } }),\n' +
' 21 async getSessionAndUser(sessionToken) {\n' +
'β 22 const userAndSession = await p.session.findUnique(\n' +
'Error occurred during query execution:\n' +
'ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E26000), message: "prepared statement \\"s56\\" does not exist", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("prepare.c"), line: Some(485), routine: Some("FetchPreparedStatement") }) }) })\n' +
' at RequestHandler.handleRequestError (/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@prisma/client/runtime/index.js:30855:13)\n' +
' at RequestHandler.request (/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@prisma/client/runtime/index.js:30834:12)\n' +
' at async PrismaClient._request (/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@prisma/client/runtime/index.js:31812:16)\n' +
' at async getSessionAndUser (/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@next-auth/prisma-adapter/dist/index.js:22:36)',
name: 'Error'
}
[next-auth][error][SESSION_ERROR]
<https://next-auth.js.org/errors#session_error>
Invalid `p.session.findUnique()` invocation in
/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@next-auth/prisma-adapter/dist/index.js:22:52
19 linkAccount: (data) => p.account.create({ data }),
20 unlinkAccount: (provider_providerAccountId) => p.account.delete({ where: { provider_providerAccountId } }),
21 async getSessionAndUser(sessionToken) {
β 22 const userAndSession = await p.session.findUnique(
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E26000), message: "prepared statement \"s56\" does not exist", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("prepare.c"), line: Some(485), routine: Some("FetchPreparedStatement") }) }) }) Error:
Invalid `p.session.findUnique()` invocation in
/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@next-auth/prisma-adapter/dist/index.js:22:52
19 linkAccount: (data) => p.account.create({ data }),
20 unlinkAccount: (provider_providerAccountId) => p.account.delete({ where: { provider_providerAccountId } }),
21 async getSessionAndUser(sessionToken) {
β 22 const userAndSession = await p.session.findUnique(
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E26000), message: "prepared statement \"s56\" does not exist", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("prepare.c"), line: Some(485), routine: Some("FetchPreparedStatement") }) }) })
at RequestHandler.handleRequestError (/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@prisma/client/runtime/index.js:30855:13)
at RequestHandler.request (/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@prisma/client/runtime/index.js:30834:12)
at async PrismaClient._request (/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@prisma/client/runtime/index.js:31812:16)
at async getSessionAndUser (/Users/neilgirardi/Projects/Personal/getitapp/node_modules/@next-auth/prisma-adapter/dist/index.js:22:36) {
name: 'GetSessionAndUserError',
code: undefined
}
The app is running on Supabase. Restarting the app server makes it go away. Any ideas on how to troubleshoot / fix this? Thanks in advance!Ofek Gabay
10/17/2022, 4:07 AMjavier g
10/17/2022, 9:12 AMHarris Rothaermel
10/17/2022, 4:54 PMDavid Ressler
10/17/2022, 6:02 PMknex
as an example):
knex({
client: 'pg',
connection: {
user: '...',
password: '...',
database: '...',
host: `/cloudsql/${INSTANCE_NAME}`
}
})
I have so far been unable to connect to Prisma using the /cloudsql
reference to my Cloud SQL instance, though.
I am able to connect if I run the Cloud SQL Auth proxy locally and do something like this:
datasource db {
provider = "postgresql"
url = "postgresql://...:...@localhost/...?host=127.0.0.1"
}
But I would ideally love to be able to connect to Prisma using the /cloudsql
host name.
Does anyone know if this is possible?Lucas Pelegrino
10/17/2022, 6:07 PMimport { ApiProperty } from '@nestjs/swagger';
import { User } from '@prisma/client';
import { Exclude } from 'class-transformer';
export class UserEntity implements User {
...
@Exclude()
password: string;
...
// If I add this constructor and call `return new UserEntity(user) at the end of my services it works, when using TypeORM that wasn't necessary.
constructor(partial: Partial<UserEntity>) {
Object.assign(this, partial);
}
}
A simple service I wrote just to validade password exclusion
@Injectable()
export class GetUserService {
constructor(private prisma: PrismaService) {}
async get(id: string): Promise<UserEntity> {
const user = await this.prisma.user.findUnique({ where: { id } });
// Again, in order for the @Exclude option to work, I have to do this.
return new UserEntity(user);
}
}
NOTE: I have Nest global serialization enabled on the app.
My goal is to have password removed from the response without having to add the constructor in the entity, I did check Prisma Docs and read about excluding fields, but the options there are to open to errors just as this one Iβm using.
Manually removing password using the select option also gives room to error, as I have to add all other fields every time, excluding only password.
So, anyone have other suggestions on how I can solve this, am I missing something?
Appreciate feedback.Stanislav Pugach
10/17/2022, 10:26 PMmodel Tenant {
id Int @id @default(autoincrement())
name String
widgets Widget[]
}
model Widget {
tenant Tenant @relation(fields: [tenantId], references: [id])
tenantId Int
id Int @default(autoincrement())
@@id([tenantId, id])
//...
}
The syntax seems to require the widgets Widget[]
field in the Tenant
model, and the question is: what would happen if the number of total records in the Widget
table is large? Is the array a proactively loaded construct, i.e. would it load the entirety of the DB at all times? Or is the array just syntactic sugar over something that is smarter than that?
Also, is there a way to not require that array field? The schema is likely to be rather large, and the Tenant
model is going to be just lines and lines of those array fields...
Disclaimer: I know there are multitenancy plugins, I'm just comparing the alternatives.Dave Edelhart
10/17/2022, 10:59 PMprisma.account.upsert({where: {email: email}, update: {}, create: {email: email}})
and not modify but return the acocunt unchanged if it exists?Harry Lee
10/18/2022, 5:01 AM@transactional
in spring)?
Iβm using Interactive Transaction feature from prisma but it is quit bothersome when especially repository layer is separated
await prisma.$transaction(async (prisma) => {
// ...
await createUser(prisma, ...)
await createReservation(prisma, ...)
await updateLocation(prisma, ...)
})
abdoaligomaa107
10/18/2022, 6:12 AMOdysseas Pap
10/18/2022, 1:55 PMmodel Column {
id String @id @default(cuid())
title String
projectId String
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
cards Card[]
}
model Card {
id String @id @default(cuid())
title String
description String?
columnId String
column Column @relation(fields: [columnId], references: [id], onDelete: Cascade)
}
I'm basically making a trello clone.
I'm using react-beautiful-dnd to rearrange the cards on a column, I thought the easiest way to update the database would be something like this
const result = await ctx.prisma.column.update({
where: {
id: input.colId,
},
data: {
cards: {
set: input.cards
},
},
include: {
cards: true
}
});
input.cards
has a type of Card[]
export type Card = {
id: string
title: string
description: string | null
columnId: string
}
But it doesn't work saying it got a wrong value...
How do I set the cards field with new array of card objects?Jose
10/18/2022, 4:22 PMDATABASE_URL
?
datasource db {
provider = "postgresql"
url = env(`postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${BRANCH_NAME}?schema=public`)
}
According to the docs, we either set the full string, or a single environment variable (but in this case we want to read the branch name for each environment)Jose
10/18/2022, 4:26 PMMatthew Knight
10/18/2022, 4:54 PMSteven Kuck
10/18/2022, 5:41 PMJacob Martin
10/18/2022, 6:55 PMAJ Holloway
10/18/2022, 6:49 PMFiltering on object key values within an array is only supported by the MySQL database connector.
Zakaria Mofaddel
10/18/2022, 7:23 PMSebastian Gug
10/18/2022, 8:17 PM// returning the search result
return await this.client.user.findUnique({where: {email}});
what's the right way of doing this? currently throws 'email' does not exist in type 'UserWhereUniqueInput'.
-- what's the expected way?Sebastian Gug
10/18/2022, 8:17 PMmodel User {
id String @id @default(uuid())
email String @unique
my user is defining email as a unique thingKevin Lanthier
10/18/2022, 8:29 PM$transaction
it leaves an idle connection afterwards.
Code looks like that:
const [items, count] = await this.prisma.$transaction([
this.prisma.user.findMany({ ...args, include: userIncludes }),
this.prisma.user.count({ where: computedWhere }),
]);