GN Vageesh
04/14/2022, 5:08 PMChris Gurba
04/14/2022, 5:39 PMyujonglee
04/15/2022, 5:13 AMOleg Rudak
04/15/2022, 7:58 AMSELECT published, COUNT(*) FROM Posts GROUP BY published
EDIT 2:
I need this, but in relation:
const data = await prisma.posts.groupBy({
by: ["published"],
_count: {
published: true,
},
});
shahrukh ahmed
04/15/2022, 12:42 PMnpx prisma generate
with a output directory provided in the Schema. My package.json
is configured with "type": "module"
. This import doesn't quite work.
import { PrismaClient } from '../../prisma-client/index.js'
let prisma = new PrismaClient();```
The error I get even when running node --experimental-specifier-resolution=node server.js
is The requested module '../../prisma-client/index.js' does not provide an export named 'PrismaClient'
Alf Fenton
04/15/2022, 2:02 PMmodel User {
id String @id @default(auto()) @map("_id") @db.ObjectId
email String @unique
description String?
name String?
username String?
password String?
followedBy User[] @relation("UserFollows", fields: [followedByIDs], references: [id])
followedByIDs String[] @db.ObjectId
following User[] @relation("UserFollows", fields: [followingIDs], references: [id])
followingIDs String[] @db.ObjectId
role Role @default(USER)
reivews Review[]
emailVerified DateTime? @map("email_verified")
image String?
accounts Account[]
sessions Session[]
@@fulltext([name(sort: Desc), username, email])
@@map("users")
}
When attempting to match/connect two existing users through the following relations with the use of Prisma client code:
await prisma.user.update({
where:{
email:'<mailto:alf@votaryfilms.com|alf@votaryfilms.com>'
},
data:{
following: {connect: [{id: data}]}
}
})
I get the following error:
The current database provider doesn't support a feature that the query used: Unhandled and unsupported value
mapping for MongoDB: 6223c13a26bb3d44fc98dad5 as Int.
If possible, could someone help point out where I'm wrong in my approach, if this is a bug perhaps, or if there are better-known ways for me to achieve the above goal?
Thanks so much 🙏Kenneth Gitere
04/16/2022, 7:11 AMVictor Meireles
04/16/2022, 6:00 PMMischa
04/17/2022, 9:55 AMBEGIN
with SAVEPOINT
(like pytest-sqlalchemy does) - is this possible to do while running my test? (edited)Brothak
04/17/2022, 9:09 PMBrothak
04/17/2022, 9:10 PMBrothak
04/17/2022, 10:01 PMmjyoung
04/18/2022, 1:03 AMlorenzo xl gomez
04/18/2022, 11:13 AMMykyta Machekhin
04/18/2022, 12:08 PM_count
field in findMany query. Project compiled without errorsAlfred Noland
04/18/2022, 1:21 PM20220413095619_init
migration started at 2022-04-18 095258.950 UTC failed with the following logs:
Does anyone has experience with this?Kadam Patel
04/18/2022, 2:11 PMQuentin Gilon
04/18/2022, 2:42 PM"message": "TypeIdentifier not yet supported in Import as ID. com.prisma.shared.models.TypeIdentifier$Int$@4a2acc6c",
"requestId": "eu1:cl24f25t66z6v09991kjjvzck"
Our app is down and so is our design service. This is super time sensitive.
Is there anyone with experience in Prisma 1 available to help (paid of course)?
@Kevin Justal is our Lead Dev.Richard
04/18/2022, 2:48 PMschema.prisma
(generated in a separate package in the same monorepo)
Question
What is the best way for me to setup the monorepo?
Problem
When I import prisma from the package in my web
app, prisma is unable to locate the schema.prisma
file:
error - Error: ENOENT: no such file or directory, open '/Users/xxx/rootDir/apps/web/.next/server/pages/api/trpc/schema.prisma'
This may be related to the following prisma issues:
• https://github.com/prisma/prisma/issues/9435#issuecomment-1065879963
• https://github.com/prisma/prisma/issues/10512 (supposed to be fixed via #12427)
Context
• I have a monorepo setup with an apps/web
nextJS app and a separate packages/database
package with prisma inside.
• The database package builds via tsup to packages/database/dist
.
apps/
├─ web/ # <-- nextJS app (unable to detect schema)
packages/
├─ database/
│ ├─ prisma/ # prisma setup
│ │ ├─ schema.prisma
│ ├─ src/
│ │ ├─ client.ts # exports PrismaClient & global.prisma type in prod
│ │ ├─ index.ts # exports from prisma client
│ │ ├─ seed.ts # prisma seeding script for local dev
│ ├─ .env.example # `DATABASE_URL` env var
│ ├─ tsup.config.js # builds to /dist folder in this package
isaacs
04/18/2022, 5:56 PMprisma.create
? I'm looking for the equivalent of:
INSERT INTO membership(orgId, email, role)
SELECT orgId, @email as email, @role as role
FROM membership
WHERE orgId = @orgId
AND userId = @userId
AND (role = 'OWNER' OR (role = 'ADMIN' AND @role = 'USER'));
so you'd call it setting the userId
to the current user taking the action, and this would assert that it would only create if the user has permission to add new users at the requested role
(I know I can do prisma.findUnique
to get the membership role of the current user, and then do it in javascript, but i try to avoid TOCTOU as a general practice.)Yunbo
04/18/2022, 6:59 PMBrothak
04/18/2022, 7:19 PMdaemon
04/18/2022, 8:28 PMType '(_: {}, args: { name: string; }, ctx: Context) => Prisma__ExchangeClient<Exchange>' is not assignable to type 'FieldResolver<"Mutation", "addExchange">'.
Type 'Prisma__ExchangeClient<Exchange>' is not assignable to type 'MaybePromise<{ id: string; name: string; } | null>'.
Type 'Prisma__ExchangeClient<Exchange>' is not assignable to type 'PromiseLike<{ id: string; name: string; } | null>'.
Types of property 'then' are incompatible.
Type '<TResult1 = Exchange, TResult2 = never>(onfulfilled?: ((value: Exchange) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<...>) | null | undefined) => Promise<...>' is not assignable to type '<TResult1 = { id: string; name: string; } | null, TResult2 = never>(onfulfilled?: ((value: { id: string; name: string; } | null) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<...>) | ... 1 more ... | undefined) => PromiseLike<...>'.
Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible.
Types of parameters 'value' and 'value' are incompatible.
Type 'Exchange' is not assignable to type '{ id: string; name: string; }'.
Types of property 'id' are incompatible.
Type 'number' is not assignable to type 'string'.ts(2322)
daemon
04/18/2022, 8:31 PMschema.prisma
and my schema.graphql
//schema.prisma
model Exchange {
id Int @id @default(autoincrement())
name String @unique
}
//schema.graphql
type Exchange {
id: ID!
name: String!
}
type Mutation {
addExchange(name: String!): Exchange
}
type Query {
exchanges: [Exchange!]!
hello: String
}
daemon
04/18/2022, 8:34 PMdaemon
04/18/2022, 9:00 PMnexus-prisma
example boilerplate project?Yunbo
04/18/2022, 10:18 PMJonas Rothmann
04/18/2022, 10:39 PMAlouani Younes
04/19/2022, 12:48 AMBen Guthrie
04/19/2022, 1:23 AMplaylistId
and videoId
as composite keys, you have a unique id
on the model. If you had the `playlistId`/`videoId` pairs, but not the id
s, is there an efficient method to find all of the rows for the pairs? (schema.prisma
and data in thread)