Paul
09/03/2021, 2:33 PMselect id, name, filterType, RANK() OVER (PARTITION BY filterType order by name asc) type_rank from DamFile;
Result:
+----------------------------+------------------+------------+-----------+
| id | name | filterType | type_rank |
+----------------------------+------------------+------------+-----------+
| 01FEP11SA9RM3YGQAKTQGKQB2Y | Folder 1 | folder | 1 |
| 01FEP0VMFZ88YP495J17SG6SN2 | exif_image1.jpg | image | 1 |
| 01FEP0VMGSF5TN5QK7V15BMYB0 | exif_image10.jpg | image | 2 |
ThanksDaniell
09/03/2021, 2:47 PMRony Fhebrian
09/03/2021, 3:30 PMPerry Raskin
09/03/2021, 6:46 PMconst prisma = new PrismaClient({ log: ["query"] })
const {
method,
query: { id },
body
} = req
const userId = id as unknown
const userIdString = userId as string
const userIdInt = parseInt(userIdString)
Perry Raskin
09/03/2021, 6:46 PMLogesh Kumar Rajkumar
09/04/2021, 10:06 AMDimitri Ivashchuk
09/04/2021, 1:03 PM10:54:13.919 Error: P3018
10:54:13.919 A migration failed to apply. New migrations can not be applied before the error is recovered from. Read more about how to resolve migration issues in a production database: <https://pris.ly/d/migrate-resolve>
10:54:13.919 Migration name: 20210904075303_add_new_heats_structure
10:54:13.919 Database error code: 23502
10:54:13.919 Database error:
10:54:13.919 Database error
10:54:13.919 Null constraint failed: (property)
10:54:13.919 0: migration_core::api::ApplyMigrations
10:54:13.919 at migration-engine/core/src/api.rs:73
10:54:13.933 error Command failed with exit code 1.
10:54:13.934 info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command.
10:54:13.950 Error: Command "yarn run vercel-build" exited with 1
First question: what would be the correct way to resolve this in two cases:
1. if I care about the data
2. if I don't care if data is lost(this is the case now, but in the future I bet it could be different)
Shall I just drop the database and redeploy on vercel? Or there is some prisma magic command that could help meWesam Jabali
09/05/2021, 12:24 AMYou don't have any models defined in your schema.prisma, so nothing will be generated.
You can define a model like this:
Wesam Jabali
09/05/2021, 12:25 AM// Default stuff ...
model Course {
id Int @id @default(autoincrement())
name String
description String
}
Wesam Jabali
09/05/2021, 12:30 AMuser
09/05/2021, 2:46 PMuser
09/05/2021, 2:46 PMuser
09/05/2021, 2:46 PMGelo
09/06/2021, 2:29 AMDaniell
09/06/2021, 8:24 AMErik C
09/06/2021, 3:31 PMuser
09/06/2021, 4:09 PMuser
09/06/2021, 4:09 PMHalvor
09/06/2021, 6:28 PMSELECT
m.*,
d.*,
AVG(r.value) AS rating
FROM "Map" AS m
JOIN "MapData" AS d ON m."id" = d."mapId"
JOIN "MapRate" AS r ON m."id" = r."mapId"
WHERE deleted = false
GROUP BY m.id, d.id
ORDER BY rating DESC
My schema:
enum MapPlatform {
XBOX360 // 1
PS3 // 2
PC // 3
}
model Map {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
user User @relation(fields: [userId], references: [id])
userId Int
platform MapPlatform @default(PC)
uuid String @unique @default(uuid())
title String
size Int
deleted Boolean @default(false)
mapData MapData?
mapRatings MapRate[]
}
model MapData {
map Map @relation(fields: [mapId], references: [id])
mapId Int
id String @id
gamemode Int
battlefieldSize Int
numberPlayers Int
originalCreatorName String
originalCreatedDate DateTime
authorName String
authorDate DateTime
thumbnail String
}
enum MapRateType {
USER
INAPPROPRIATE
}
model MapRate {
map Map @relation(fields: [mapId], references: [id])
mapId Int
user User @relation(fields: [userId], references: [id])
userId Int
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
type MapRateType @default(USER)
value Int
@@id(fields: [mapId, userId])
}
What i want to achieve is to maps sorted by the average of value
from the MapRate table, that has a relation with Map table.
I imagine this would require both group by and aggregate functions combined with the findMany() is that even possible with prisma?Miguel A. C.
09/07/2021, 9:59 AMÁvila
Cáceres
Cantabria
Ceuta
But I get the following:
Cantabria
Ceuta
Cáceres
Ávila
I'd like to sort using unicode but I haven't found how to do that. Currently I'm using sqlite as my db provider. Could you point me if there's anything I can set at Prisma or Sqlite level?
Thanks in advance!user
09/07/2021, 10:59 AMprovidenz
09/07/2021, 12:13 PMYeonHoPark
09/07/2021, 12:32 PMconst user: NexusGenObjects["User"] = ...
How do you all user graphql type in typescript? create it manually ?
I tried using graphql-code-generator, it was a pity that it did not check whether the resolver of the type field was implemented.Josef Henryson
09/07/2021, 2:42 PManiraga
09/07/2021, 2:47 PM...
exports.graphqlHandler = (
event: APIGatewayProxyEvent,
context: Context,
callback: APIGatewayProxyCallback
) => {
context.callbackWaitsForEmptyEventLoop = false
const server = new ApolloServer({
schema: schema,
context: schemaContext,
})
const handler = server.createHandler()
return handler(event, context, callback)
}
Erick Petrucelli
09/07/2021, 2:53 PMNULL
values on columns I want to search. It would be easy to use a COALESCE
with a raw query, but I'd like to know: is there a way to force the NULL
values to empty strings in Prisma itself when querying data?Hyo
09/07/2021, 2:56 PMPrisma
in termux?user
09/07/2021, 4:10 PMJacob Simon
09/07/2021, 4:14 PMPrismaClient
for each model? E.g. if I have a model User
and Article
is there a base type for prisma.user
such that I can have a function that would accept prisma.user
or prisma.article
like function genericSelect(modelRepo: SomeBaseType)
?Alex Okros
09/07/2021, 6:01 PM