Kay Khan
09/01/2021, 8:05 PMprismaschemas/prod.schema.prisma
prismaschemas/dev.schema.prisma
package.json
"scripts": {
"prisma-prod": "mv prismaschemas/prod.schema.prisma ./schema.prisma
"prisma-dev": "mv prismaschemas/dev.schema.prisma ./schema.prisma
"prisma-refresh": "prisma db pull && prisma generate"
}
Then depending on your environment you can run either prisma-prod
| prisma-dev
then prisma-refresh
. Modify prisma-refresh if you need to do migration.Kay Khan
09/01/2021, 8:13 PMprisma db pull
.
So i will create a seperate views.schema.prisma
file that contains my custom models (views). I should then be able to run prisma pull db
and then merge views.schema.prisma
then finally prisma generate
to get the prisma client.
Views not being supported is not great for us, without this hack the library is just unusable for me as views is pretty important for us.Rodrigo Scomação do Nascimento
09/01/2021, 10:03 PMRodrigo Scomação do Nascimento
09/01/2021, 10:03 PMPieter
09/02/2021, 12:32 AMTyler Clendenin
09/02/2021, 3:10 AMNotFoundError
thrown from the `findFirst`'s rejectOnNotFound
option. the NotFoundError
class/type doesn't seem to be exposed to be imported.Jacob Simon
09/02/2021, 3:40 AMtype Map<T> = {
[P in keyof T]: T[P]
}
type test3 = Map<PrismaModel>
I would expect nullable properties to be nullable in the mapped result, but they're not. If I copy and paste the type definition into my types file and use the Map<T>
type then the nullable properties remain nullable. Am I missing something here?Timo
09/02/2021, 8:13 AMfindFirst
an item and set a lock property immediately or with a following update
transaction. What is the best way to do this?Timo
09/02/2021, 8:14 AMTimo
09/02/2021, 8:16 AMconst item = await prisma.item.findFirst({where: {isReady: true, isReserved: false}})
Timo
09/02/2021, 8:17 AMif(item) await prisma.item.update({where: {name: item.name}, data: {isReserved: true, lastReserve: moment.utc().toDate()}})
Kay Khan
09/02/2021, 8:49 AMKrishna Chaitanya
09/02/2021, 9:25 AMDev__
09/02/2021, 10:04 AMcatch(error) {
if (error instanceof AnyPrismaError) {
...
}
}
Ippo
09/02/2021, 10:10 AMNditah Samweld
09/02/2021, 1:04 PMError: Cannot determine a GraphQL input type for the "company". Make sure your class is decorated with an appropriate decorator."
I have gone through and through the project since yesterday and google it. Yet no clue.
Thanks in advance
@Dominic HadfieldNaotho Machida
09/02/2021, 2:07 PMPrismaClientUnknownRequestError2 [PrismaClientUnknownRequestError]: Attempted to serialize scalar 'null' with incompatible type 'String' for field condominioId.
Luis Haroldo Castro Cabrera
09/02/2021, 2:21 PMMax Torre Schau
09/02/2021, 3:31 PMHarjaap Singh Makkar
09/02/2021, 4:36 PMObject literal may only specify known properties, and 'path' does not exist in type 'JsonNullableFilter'.
Matt Langer
09/02/2021, 6:50 PMmodel User {
id String @id @default(uuid())
givenName String
familyName String
}
if i want to perform a LIKE query against that table, it is quite simple to search for either the given name or the family name, but it is unclear to me how to use Prisma to search for a full name across both columns. in PostgreSQL i could do the following,
WHERE (User.givenName || ' ' || User.familyName) LIKE ...
is something like this possible with prisma?Kay Khan
09/02/2021, 7:47 PMexport const PersonResolvers = {
Query: {
person: Person,
},
Person: {
data1: data1,
data2: data2,
data3: data3,
},
};
Alan
09/02/2021, 8:31 PMprisma migrate resolve --applied "20201127134938_my_migration"
but for All migrations?
My prod database has 10 migrations. I just created a new environment with a fresh new database. I ran npx prisma db push
. But the table _prisma_migrations
is empty. So if I run npx prisma mograte
it will drop an error as he will try to apply old migrations.Cleberson Saller
09/02/2021, 9:04 PMJonas Rothmann
09/03/2021, 1:01 AMprisma.customer.findFirst({ where: { id: 11 }, include: { visits: { where: { status: "completed" } } } })
returns customers with visits where status can be any string or even null?Jonas Rothmann
09/03/2021, 1:13 AMSaul Nachman
09/03/2021, 6:19 AMVladi Stevanovic
Mykyta Machekhin
09/03/2021, 9:58 AMcreateMany
, or I can do it by multiple call of create
only?Florian
09/03/2021, 1:32 PMmodel A {
id String @id
// A can exist without B
mainB B? @relation(name: "AB", fields: [mainBID], references: [id])
mainBID String?
secondB B? @relation(name: "AB", fields: [secondBID], references: [id])
secondBID String?
}
enum BType {
MAIN
SECOND
}
model B {
id String @id
type BType
// B must be attached to an A to exist
a A @relation(name: "AB", fields: [aID], references: [id])
aID String
@@unique([type, aID])
}
Am I forced to do a 1-m relation (ie. replace mainB
and secondB
with bs B[]
in model A
) or is it possible to achieve something like this?
Even when I tried to add names to the relations it was still ambiguous for prisma :(
Something I didn't try but I think would look terrible, is to completely separate the 1-1 relations (i'd like to refer to A from B without needing to check type
to know which key to include in the query + I need to make sure B is linked to an A), ie.
model A {
id String @id
mainB B? @relation(name: "MainAB")
secondB B? @relation(name: "SecondAB")
}
enum BType {
MAIN
SECOND
}
model B {
id String @id
type BType
mainA A? @relation(name: "MainAB", fields: [mainAID], references: [id])
mainAID String?
secondA A? @relation(name: "SecondAB", fields: [secondAID], references: [id])
secondAID String?
}
If you have any suggestion I'd be happy to hear ^^