Julian
06/13/2022, 2:43 PMconst amountMale = await this._prismaService.$queryRaw`
SELECT
COUNT(profile) as count
FROM "public"."User" AS user, "public"."Profile" AS profile
WHERE user.profileId = profile.id
WHERE profile.gender = MALE
`
I get the following error:
Raw query failed. Code: `42601`. Message: `db error: ERROR: syntax error at or near "user"`
It is solved by removing the AS user
and AS profile
parts, but then it gives an error on WHERE User.profileId = Profile.id
saying the .
is an invalid character.
Is there any way to solve this? Prisma version is 3.13, using Postgresqlmans
06/13/2022, 3:00 PMmodel Product {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String @unique @db.VarChar(255)
description String?
price Float
published Boolean @default(true)
// een relatie van alle orders met dit product erin
orders Order[]
}
model Order {
id Int @id @default(autoincrement())
clientName String
email String
placedAt DateTime @default(now())
status Status @default(PLACED)
Products Product[]
}
Nvm i figured it outMoin Akhter
06/13/2022, 6:32 PMprisma chobo
06/13/2022, 6:39 PMprisma.agent.findMany({
where: {
teamId: id,
deletedAt: null (undefined)
},
});
my schema is like so
model Agent {
id String @id @default(auto()) @map("_id") @db.ObjectId
teamId String
deletedAt Int?
}
This always empty array whether deletedAt is set or deletedAt is null or undefined...
aprisma chobo
06/13/2022, 6:39 PMJack Wright
06/13/2022, 7:38 PMJack Wright
06/13/2022, 7:47 PMJack Wright
06/13/2022, 9:38 PMmodel User {
id Int @id @default(autoincrement())
firstname String
lastname String
username String @unique
email String @unique
password String
tel String?
country String?
bio String?
mealIds Meal[]
}
model Meal {
id Int @id @default(autoincrement())
name String @unique
about String
Owner User @relation(fields: [ownerId, likedUserIds], references: id) <--- Prisma does not like this
ownerId Int
likedUserIds Int[]
}
Mehul Gogri
06/13/2022, 10:01 PMmatt murphy
06/14/2022, 10:49 AMTicket
model and a TicketTag
model, pretty much building a support ticketing system, however, I wish to add tags.
pretty much how it's documented to implement such a feature is to use a many-to-many implementation as so:
model Ticket {
id String @id @default(auto()) @map("_id") @db.ObjectId
title String
editedAt DateTime?
createdAt DateTime
ticketTags TicketTag[] @relation(fields: [ticketTagIds], references: [id])
ticketTagIds String[] @db.ObjectId
user User @relation(fields: [userId], references: [id])
userId String @db.ObjectId
}
model TicketTag {
id String @id @default(auto()) @map("_id") @db.ObjectId
title String
description String?
attributes Json
editedAt DateTime?
createdAt DateTime
tickets Ticket[] @relation(fields: [ticketIds], references: [id])
ticketIds String[] @db.ObjectId
}
But it seems incredibly unoptimized to stack for example 50,000 tickets into the ticketIds
field on the TicketTag
, as I'm aware MongoDB has a 16MB document limit.
My question is, is how can I get only Ticket
to store the ticketTagIds
without also doing the same on TicketTag
modelMcKay Bonham
06/14/2022, 12:21 PM<mongodb://mongo_db_admin>:<password for mongo_db_admin>@127.0.0.1/<database name>?retryWrites=true&w=majority&ssl=true
I've tried many variations on this URL, including putting a port after the hostname. I'm presenting the version that seems to get furthest before throwing an error.Matthew Drooker
06/14/2022, 12:54 PMJulian
06/14/2022, 1:29 PMfirstName
, lastName
, street
, houseNumber
, and if I only provide a name John Doe
it should return all John Doe's. But if I search for John Doe Mainroad 15
it should only return the John Doe on Mainroad 15.
I currently have a OR: []
clause with contains
/`search` conditions, but because of the OR
it also returns all entires with house number 15. But with AND
it would not return any result, so I can't use that either.Gert
06/14/2022, 3:57 PMRahul Taing
06/14/2022, 4:02 PMerror TS2345: Argument of type '() => { __esModule: boolean; default: { $on: CalledWithMock<void, ["beforeExit", (event: () => Promise<void>) => void]>; $connect: CalledWithMock<Promise<void>, []>; ... 8 more ...; readonly prismaExampleTable: any; } & PrismaClient<...>; }' is not assignable to parameter of type 'MockModuleFactory<{ __esModule: boolean; default: { $on: CalledWithMock<void, ["beforeExit", (event: () => Promise<void>) => void]>; $connect: CalledWithMock<Promise<void>, []>; ... 8 more ...; readonly prismaExampleTable: any; } & PrismaClient<...>; }>'.
Type '{ __esModule: boolean; default: { $on: CalledWithMock<void, ["beforeExit", (event: () => Promise<void>) => void]>; $connect: CalledWithMock<Promise<void>, []>; ... 8 more ...; readonly prismaExampleTable: any; } & PrismaClient<...>; }' is not assignable to type '{ __esModule: boolean; default: { $on: CalledWithMock<void, ["beforeExit", (event: () => Promise<void>) => void]>; $connect: CalledWithMock<Promise<void>, []>; ... 8 more ...; readonly prismaExampleTable: any; } & PrismaClient<...>; } & { ...; }'.
Type '{ __esModule: boolean; default: { $on: CalledWithMock<void, ["beforeExit", (event: () => Promise<void>) => void]>; $connect: CalledWithMock<Promise<void>, []>; ... 8 more ...; readonly prismaExampleTable: any; } & PrismaClient<...>; }' is not assignable to type '{ __esModule: true; }'.
Types of property '__esModule' are incompatible.
Type 'boolean' is not assignable to type 'true'.
Jack Pordi
06/14/2022, 4:14 PMbinaryTarget
s cause the client building step to bundle all of those binaries in? I’m having this error:
Query engine library for current platform \"linux-musl\" could not be found.\nYou incorrectly pinned it to linux-musl\n\nThis probably happens, because you built Prisma Client on a different platform.
Even though my binaryTarget
included both native
and linux-musl
Germa Vinsmoke
06/14/2022, 4:34 PMGerma Vinsmoke
06/14/2022, 4:51 PMMatias
06/14/2022, 4:59 PMAtharva Bhange
06/14/2022, 6:58 PMRUN
command of npx prisma generate
when i build my image i am getting error Error: Get config: Unable to establish a connection to query-engine-node-api library
The base image of my dockerfile is node:16-slim
my prisma schema ha
generator client {
provider = "prisma-client-js"
binaryTargets = ["native"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
Any Ideas why this is happening ?lawjolla
06/14/2022, 7:27 PMfindMany
preserve id ordering? E.g. …
const getUser = await prisma.user.findMany({
where: {
id: { in: [22, 91, 14, 2, 5] },
},
})
and guarantee the order of the users is always 22, 91, etc?
I can only come up with a manual solution, but I’m not sure how performant it is against Prisma’s findMany, e.g.
const getUsers = (await Promise.all(ids.map(id => prisma.user.findUnique({ where: { id }})))
e
06/14/2022, 8:50 PMe
06/14/2022, 8:51 PMtypePaths:
process.env.NODE_ENV !== "production" || process.env.IS_OFFLINE
? ["**/*.graphql"]
: ["*.graphql"],
e
06/14/2022, 8:55 PM"errorMessage": "No type definitions were found with the specified file name patterns: \"*.graphql\".```
Moin Akhter
06/14/2022, 11:37 PMGelo
06/15/2022, 2:25 AMIan Alexander Abac
06/15/2022, 3:33 AMOkan Yıldırım
06/15/2022, 8:16 AMBerian Chaiwa
06/15/2022, 9:52 AMPrismaClientKnownRequestError
into some nice json
object like : {code: "P2002",message:"some msg"}
? Can be helpful to reuse when looking up these error codes. If not, I will type them all out 🙂Joonatan
06/15/2022, 1:51 PMSELECT * FROM "Example" WHERE "date" > '2020-10-10'
it works fine. But how to pass the date as variable?
I have tried it like this:
_let_ fromStr = dayjs(from).format("YYYY-MM-DD");
`Prisma.queryRaw`SELECT * FROM "Example" WHERE "date" > '${fromStr}'`` and also without the single quotes but it throws “ERROR: invalid input syntax for type date: \“$1\“” each time