David A. Black
12/24/2021, 9:39 AMlib/utils.js
file that uses prisma client, and utils are used in a getServerSideProps
. I’m doing the global prisma client technique. But I have to import prisma in the page, not the utils file. And I get the browser-running error unless I simply refer to prisma
in the getServerSideProps
. So I literally have a line that looks like: var thisPreventsThePrismaClientError = prisma
David A. Black
12/24/2021, 9:40 AMMischa
12/28/2021, 8:26 AMMischa
12/28/2021, 10:18 AMDavid
01/03/2022, 10:33 PMmeta
is of type object in prisma client? Seems like Record<string, unknown>
would be more appropriate. Personally I'm trying to access error.meta.target
but of course TypeScript isn't happy about that because object
is supposed to be equivalent to {}
and thus even with optional chaining this is still invalid. So far seems like my only options are to PR and ts-ignore/coerce to any, but this is really not ideal... and I wanna make sure this is a mistake before I PR.
export declare class PrismaClientKnownRequestError extends Error {
code: string;
meta?: object;
clientVersion: string;
constructor(message: string, code: string, clientVersion: string, meta?: any);
get [Symbol.toStringTag](): string;
}
Tyler Bell
01/04/2022, 4:22 AMmodel App {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime? @updatedAt
name String
redirects Redirects[]
@@index([slug], map: "App.slug_index")
}
model Redirects {
id String @id @default(cuid())
global Boolean
afterSignup String?
afterLogin String?
afterLogout String?
appId String
app App @relation(fields: [appId], references: [id])
}
I want to update a single record that matches an appId
and where global
is true
If a record doesn’t match that, I would like it to be created.
Having difficulties doing that tho, since the upsert
method only accepts the id
field in the where
argument.
So what’s the best way to do this? The following code is essentially what I’m trying to do.
prisma.redirects.upsert({
where: {
appId,
global:true
},
create: {
...redirects,
app: { connect: { id: appId } },
},
update: {
...redirects,
app: { connect: { id: appId } },
}
})
Thanks!Adrian
01/07/2022, 8:50 AMaThing
, bThing
). But the data comes async over a eventbus. So it can happen, that aThing
trys to reference an ID from bThing
, that is currently not there. How can I describe this in the schema, so that I dont get an `Foreign key constraint failed on the field`error?Aman Tiwari
01/09/2022, 9:33 PMconst enquiry = await db.enquiry.findFirst({
where: { id },
include: {
users: {
include: {
user: true,
},
},
},
})
if (!enquiry) throw new NotFoundError()
const partner = enquiry.users.filter((arr) => arr.user.role === "PARTNER")[0]
const customer = enquiry.users.filter((arr) => arr.user.role === "USER")[0]
return { ...enquiry, partner, customer }
is this good idea? what are the other way to do?Mischa
01/11/2022, 11:29 AMMischa
01/11/2022, 11:30 AMthis.model.groupBy({
by: ["id"], // <- what goes here?
_avg: {}, // <- what goes here?
orderBy: {_avg:{}},// <- what goes here?
where: {
AND: [
{ CandidateVacancyMatch: { every: { isLatest: true } } }, // latest matches
this.filterForUserRead(user),
],
},
})
Oyewole ABAYOMI S.
01/13/2022, 1:08 AMconst i = await this.prisma.transactions.groupBy({
by: ['status'],
where: {
status: { in: ['APPROVED', 'COMPLETED', 'PENDING'] }
},
_count: {
status: true
}
})
console.log(i) // []
// i need something like
// {approved: 0, pending: 0, completed: 0}
Thank you.Tom McKenzie
01/17/2022, 12:07 AMMischa
01/17/2022, 3:46 PM/Users/cyber/dev/platform/node_modules/@prisma/client/runtime/index.js:39054
throw new PrismaClientUnknownRequestError(message, this.client._clientVersion);
^
PrismaClientUnknownRequestError:
Invalid `prisma.candidate.findUnique()` invocation:
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: FromSql(4), cause: Some(WasNull) }) })
at Object.request (/Users/cyber/dev/platform/node_modules/@prisma/client/runtime/index.js:39054:15)
at async CandidateRepository.getByIdOr404 (file:///Users/cyber/dev/platform/packages/service/src/repo/repository/base.ts:82:17)
KATT
01/17/2022, 7:40 PM@map
-ing the relationship tables - for instance i want my _OrgToUser
join table to be _org_to_user
? i can’t seem to find it in the docsAlonso A.
01/18/2022, 4:55 AMAlonso A.
01/18/2022, 4:56 AMAlonso A.
01/18/2022, 4:57 AMAndrew Ross
01/18/2022, 6:09 AM// see <https://www.apollographql.com/docs/tutorial/data-source/>
import { RequestOptions, RESTDataSource, Request, Response } from "apollo-datasource-rest";
//...
export class ZenApi extends RESTDataSource<Request> {
constructor() {
super();
}
baseURL = `https://${
process.env.ZEN_SUBDOMAIN || ""
}.<http://zendesk.com/api/v2/`;|zendesk.com/api/v2/`;>
// do stuff -- get post etc
async zenPostUserCreateTicket(ticketInput: ZenUserCreateTicketInput) {
return await <http://this.post|this.post><ZenSyncUserTicketOutput>('tickets', { ticketInput }).then((ticket) => ticket)
}
}
// IN THE SERVER FILE
const server = new ApolloServer({
schema,
typeDefs,
apollo as ApolloConfigInput,
playground: isProdEnvironment() === false,
dataSources: (): DataSources<object> => {
return {
zenApi: new ZenApi()
}
},
async context({ req, res }): Promise<Context> { /*return prisma in context*/}
but first try returning prisma as typeof PrismaClient in your server's context so you can access it in GraphQLContext as well as in RequestContextsunech
01/20/2022, 11:07 AMYaakov
01/25/2022, 5:41 PMUser
and InternalUserProfile
only when User.type = INTERNAL
.
model User {
id Int @id @default(autoincrement())
type UserType
internalUserProfile InternalUserProfile?
}
model InternalUserProfile {
user User @relation(fields: [userId = User.id AND User.type = 'INTERNAL'], references: [id])
userId Int
}
enum UserType {
INTERNAL
EXTERNAL
}
Thank you!Barnaby
01/26/2022, 5:49 PM-W
or --ignore-workspace-root-check
? breaking builds in a monorepo
error Running this command will add the dependency to the workspace root rather than the workspace itself, which might not be what you want - if you really meant it, make it explicit by running this command again with the -W flag (or --ignore-workspace-root-check).
Barnaby
01/26/2022, 5:53 PMprisma migrate reset --force
in our CI builds (it was for integration tests)Barnaby
01/26/2022, 5:56 PMBarnaby
01/26/2022, 5:56 PM--skip-generate
Nothing.
01/28/2022, 10:02 AMNecmettin Begiter
01/28/2022, 10:21 AMManthan Mallikarjun
01/30/2022, 5:37 AMFred The Doggy
01/31/2022, 2:34 AMFred The Doggy
01/31/2022, 2:34 AMFred The Doggy
01/31/2022, 2:34 AM