Andrew Gold
05/10/2020, 5:56 PMMartïn
05/11/2020, 5:11 PMMaurits
05/16/2020, 1:40 PMdeleteMany
?Corey Snyder
05/19/2020, 2:06 AMimport {prisma} from './generated/prisma-client/index.js'
or
import prisma from './generated/prisma-client/index.js'
Corey Snyder
06/06/2020, 6:53 PMCorey Snyder
06/07/2020, 3:18 AM{
human(id: "1000") {
name
height
}
}
but when I typed id
it kept trying to autocomplete it to where
and nothing I tried would really work.Lucas Munhoz
06/11/2020, 6:08 AMprisma.user.findOne({...})
I would like to get the query statement only and don't make the call.
I know is possible to enable logs in the prisma client, but I am looking for something more specific where I can access the query builder result instead.
Something like prisma.user.findOne({...}).getRawQuery().
That would not make any call to the db but just get the query statement from the engine. Would be awesome!
Any directions on how I can accomplish this? Thank you!Gabriel Benson
06/14/2020, 10:14 PMprisma.user({ id }).boxes({ where: { number: boxNumber } }).slots({ where: { number: slotNumber } });
lkbr
06/18/2020, 3:40 PMgetServerSideProps()
+ PromiseReturnType<typeof fn>
(where fn
is the function that returns prisma data)?
Basically, defining type X = PromiseReturnType<typeof fn>
seems to break Nexts automatic client side bundling elimination and includes fn
(which contains prisma) client side. Which then means you get the Module not found: Can't resolve 'child_process' in...
error.
Am I doing something wrong is that specific combination not going to work?Thomas
06/26/2020, 2:38 PMError:
Invalid `prisma.project.findMany()` invocation in
webpack-internal:///./packages/prisma/repository/Project.ts:41:84
Unknown error in Prisma Client
This is a non-recoverable error which probably happens when the Prisma Query Engine has a panic.
I don't get it because the query only works every other time. How if the server was overloaded or something...
I use NextJS and Prisma (both are up to date in terms of versions) with Postgres in database
Do you have a lead or an idea ? Do we need to set up a pgBouncer?Corey Snyder
07/10/2020, 3:50 PMtype Frame{
id: ID! @id
primaryBoardSize: HolePattern
supportedBoardSizes: [HolePattern] @scalarList(strategy: RELATION)
}
And I just noticed that I have no search methods for supportedBoardSizes
in the generated client FrameWhereInput
. Where as for primaryBoardSize
I am offered the method primaryBoardSize_in, primaryBoardSize_not_in, primaryBoardSize, primaryBoardSize_not
to search on.
Does anyone know a workaround for this. I’d really like to be able to offer an ability to query where Frame.supportedBoardSizes
includes [insert board size here]Omar Harras
08/02/2020, 4:49 PMInvalid prisma invocation
Here is an example with a simple mutation :
async createItem(parent, args, context) {
const item = await context.prisma.item.create(
{
data: { ...args },
},
);
return item;
},
// Got this error
"message": "\nInvalid `prisma.item.create()` invocation
Pieter
08/07/2020, 12:56 PMThomas
08/19/2020, 1:51 PMmodel ProjectPro {
id Int @default(autoincrement()) @id
name String
slug String @unique
type TypeProjectPro @default(PLUGIN)
settings_users_pro SettingsUserPro[] @relation(references: [id])
created_at DateTime? @default(now())
updated_at DateTime? @updatedAt
deleted_at DateTime?
}
model SettingsUserPro {
id Int @default(autoincrement()) @id
userId Int
type String? @default("month")
User User @relation(fields: [userId], references: [id])
projects_pro ProjectPro[] @relation(references: [id])
created_at DateTime? @default(now())
updated_at DateTime? @updatedAt
deleted_at DateTime?
}
I'd like to associate a "project pro" with a "settings user pro"Thomas
08/19/2020, 1:51 PMawait prisma.settingsUserPro.update({
data: {
projects_pro: {
set: {
id: Number(projectProId),
},
},
},
where: {
id: Number(userId),
},
});
Thomas
08/19/2020, 1:52 PMAssertionError("[Query Graph] Expected a valid parent ID to be present for a nested set (disconnect part) on a many-to-many relation.
Thomas
08/19/2020, 1:52 PMThomas
08/19/2020, 2:12 PMGreg Egan
08/20/2020, 9:51 PMmodel BrandCategory {
id String @id
title String
hero String?
brands Brand[]
}
const BrandCategory = objectType({
name: "BrandCategory",
definition(t) {
t.string("id");
t.string("title");
t.string("hero", {
nullable: true,
});
t.list.field("brands", {
type: "Brand",
resolve: (parent) =>
prisma.brandCategory
.findOne({
where: { id: String(parent.id) },
})
.brands(),
});
},
});
Hi all - i'm getting typescript errors on my relational BrandCategory <-> Brand object. ANy idea what I need to do to handle this PromiseLike / MaybePromise issue?
Type 'Promise<Brand[]>' is not assignable to type 'PromiseLike<{...}>
Type 'Promise<Brand[]>' is not assignable to type 'MaybePromise<{...}>
Pieter
08/31/2020, 7:15 AMed
09/11/2020, 3:30 PMfindMany
equivalent. Imagine I want to select users in 10 buckets based on their id
.
Schema:
model User {
id Int @default(autoincrement()) @id
email String
...
}
Query: (Get me all users with an id ending in “1”)
SELECT id FROM public.user
WHERE
id % 10 = 1
ORDER BY id DESC
Does this require a queryRaw
or is possible with an IntFilter
or some other thing I can pass into findMany
?Emmanuel
09/22/2020, 5:44 PMschema.prisma
file with all the required info. When I run prisma generate
, I expect the models defined in the schema file to create tables in the database but that’s not the case. I’m not sure if I’m missing something.Gabriel Alcântara Bernardes
10/01/2020, 8:15 PMLucas Munhoz
10/16/2020, 7:53 AMinclude
argument to a wrapper class that I have around prisma and still get the dynamic types in the inferred return type?
The usecase is that I have a multi tenant application, and in the upper level of the api calls we have a tenantId
that we want to inject in all where
arguments.
Example:
public find = ({ where, ...args }: FindManyProductArgs) =>
this.prisma.product.findMany({
where: { ...where, tenantId: this.identity.tenantId, ...args }
})
So this allow to safely call this function passing arguments without having to worry it will access another tenant data. But the problem is that the caller of find
, when it passes includes, it doesn't correcly add the dynamic types includes. This only works if I pass the include
directly to prisma instance.
I can give more examples if is not clear, but my workaround to get this working is to do this: (is very ugly);
public find: PrismaClient["product"]["findMany"] = ({ where, ...args }) =>
this.prisma.product.findMany({
where: { ...where, tenantId: this.identity.tenantId, ...args } as any
}) as any
I have to add any
everywhere to make TS happy.tatchi
10/16/2020, 10:57 PMPascal Sthamer
10/19/2020, 1:26 PMprisma-client-js
generates the following invalid TypeScript types t.crud.updateOne*
export type Game_server_port.gameServerId_binding_protocol_uniqueCompoundUniqueInput = {
gameServerId: number
binding: number
protocol: GameServerPortProtocol
}
export type Game_server_port.gameServerId_identifier_uniqueCompoundUniqueInput = {
gameServerId: number
identifier: string
}
export type Game_server_port.gameServerId_number_protocol_uniqueCompoundUniqueInput = {
gameServerId: number
number: number
protocol: GameServerPortProtocol
}
export type Game_server_setting.gameServerId_gameSettingId_uniqueCompoundUniqueInput = {
gameServerId: number
gameSettingId: number
}
export type Game_server_setting_preset.gameServerId_name_uniqueCompoundUniqueInput = {
gameServerId: number
name: string
}
Jared Hanstra
10/28/2020, 4:58 AMnpx prisma generate
. i'm an AWS newbie, so maybe something is set up incorrectly there? but i'm not sure what.
Authentication failed against database server at `<postgres-url>`, the provided database credentials for `<user>` are not valid.
Please make sure to provide valid database credentials for the database server at `<postgres-url>`.
at $w.request (/Users/jh/coprime/hq/node_modules/@prisma/client/runtime/index.js:212:54)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
code: 'P1000',
clientVersion: '2.9.0',
meta: {
database_user: 'coprime',
database_host: '<postgres-url>'
}
}
Oliver Evans
10/30/2020, 9:14 PMgraphql-nexus
channel:
I'm using nexus & the prisma 2 plugin - I'm wondering if it's possible to access the contents of schema.prisma
from nexus to programmatically expose my types.
Specifically, if I have the following in `schema.prisma`:
model Person {
name String
age Int
}
I would like to construct the following javascript object:
{
name: "String",
age: "Int"
}
Thanks!blocka
11/05/2020, 2:24 PMConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState("22021"), message: "invalid byte sequence for encoding \"UTF8\": 0x00", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("wchar.c"), line: Some(2017), routine: Some("report_invalid_encoding") }) }) })
I tried to replicate this in "raw" postgres:
insert into test (foo) values ('{"a":1}')
and it fails with
invalid input syntax for type json
however
insert into test (foo) values ('{"a": 1}')
adding a space
insert into test (foo) values ('{"a":"1"}')
or sending a string works fineUddhavNavneeth
11/08/2020, 8:03 AMtype User {
id: ID! @id
name: String!
username: String! @unique
}
type Friend {
id: ID! @id
user1: User! @relation(name: "FriendToUser1", onDelete: SET_NULL)
user2: User! @relation(name: "FriendToUser2", onDelete: SET_NULL)
status: Int!
}
How do set this up properly, I want to set up a field called Friends in the type User which is linked to type Friend and which Cascades onDelete. Main issue is the fact that Friend has 2 users in it because of which I am unable to set up a direct relation. Due to the current scenario I'm not being able to delete Users also as relation would get violated. Please give me recommendations.