Guillaume630
Guillaume630
PPrisma
Created by Guillaume630 on 9/17/2024 in #help-and-questions
How to partition a database
Is there a way to partition a PostgreSQL database using Prisma? Or is it planned in the roadmap? It might be very useful for handling large amounts of data.
1 replies
PPrisma
Created by Guillaume630 on 7/18/2024 in #help-and-questions
Sort by nulls
Is there a way to sort and not show nulls or empty strings? I added last: null, but it doesn't work :
this.prisma.toSource.findMany({
where,
take: takeCount,
skip: skipCount,
orderBy: [
{
[dto.orderBy.value]: {
sort: dto.orderBy.direction,
nulls: 'last'
}
},
{ TITLE: { sort: 'asc', nulls: 'last' } },
{ ID_CONCURRENT: { sort: 'asc', nulls: 'last' } }
]
}),
this.prisma.toSource.findMany({
where,
take: takeCount,
skip: skipCount,
orderBy: [
{
[dto.orderBy.value]: {
sort: dto.orderBy.direction,
nulls: 'last'
}
},
{ TITLE: { sort: 'asc', nulls: 'last' } },
{ ID_CONCURRENT: { sort: 'asc', nulls: 'last' } }
]
}),
2 replies
PPrisma
Created by Guillaume630 on 6/5/2024 in #help-and-questions
Update Prisma CLI
Hey, how do I update the Prisma CLI to get the latest features? Are there any migration files to apply for production?
2 replies
PPrisma
Created by Guillaume630 on 5/23/2024 in #help-and-questions
How to order multiple index
I have a index with multiple fields, i want to order them by company_id at first, but when i'm looking at my BD, it doesn't appear in first index :
@@index([company_id, CATEGORY_FINAL, GROUP_MATRIX_GROUP, TOP_PRODUCT, NRICHER_PRIO_COMPETITOR, BRAND, GROUP_CONCURRENT, MODEL, E_TRUSTED, likeStatus], name: "idx_pricing_company_id")
@@map("pricings")
@@index([company_id, CATEGORY_FINAL, GROUP_MATRIX_GROUP, TOP_PRODUCT, NRICHER_PRIO_COMPETITOR, BRAND, GROUP_CONCURRENT, MODEL, E_TRUSTED, likeStatus], name: "idx_pricing_company_id")
@@map("pricings")
here is the result : pricings idx_pricing_company_id NRICHER_PRIO_COMPETITOR, CATEGORY_FINAL, GROUP_CONCURRENT, GROUP_MATRIX_GROUP, BRAND, E_TRUSTED, company_id, MODEL, likeStatus, TOP_PRODUCT pricings pricings_pkey id
4 replies
PPrisma
Created by Guillaume630 on 5/2/2024 in #help-and-questions
Deploy on GCP
Hey, i'm deploying my NestJS application on GCP cloud run, using Prisma, but I still have this error : The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Logs for this revision might contain more information. However, I did what was necessary regarding environment variables, here is my entry point in NestJS :
import { NestFactory } from '@nestjs/core'
import { AppModule } from './app.module'
import * as dotenv from 'dotenv'
import { BadRequestException, Logger, ValidationPipe } from '@nestjs/common'
import { SwaggerExcludeFilter } from './swagger/swagger-exclude-filter.service'
// eslint-disable-next-line @typescript-eslint/no-var-requires
const cookieParser = require('cookie-parser')

async function bootstrap() {
dotenv.config()

const app = await NestFactory.create(AppModule, { cors: true })

await SwaggerExcludeFilter.setup(app)

app.enableCors({
origin: process.env.URL_FRONT,
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
preflightContinue: false,
optionsSuccessStatus: 204,
credentials: true
})

app.useLogger(new Logger())
app.useGlobalPipes(
new ValidationPipe({
whitelist: true,
forbidNonWhitelisted: true,
transform: true,
disableErrorMessages: false,
exceptionFactory: errors => {
return new BadRequestException(
errors.map(
error =>
`${error.property} errors: ${Object.values(
error.constraints
).join(', ')}`
)
)
}
})
)

app.use(cookieParser())

const PORT = process.env.PORT || 8080
const HOSTNAME = process.env.HOSTNAME || '0.0.0.0'

await app.listen(PORT, HOSTNAME)
}
bootstrap()
import { NestFactory } from '@nestjs/core'
import { AppModule } from './app.module'
import * as dotenv from 'dotenv'
import { BadRequestException, Logger, ValidationPipe } from '@nestjs/common'
import { SwaggerExcludeFilter } from './swagger/swagger-exclude-filter.service'
// eslint-disable-next-line @typescript-eslint/no-var-requires
const cookieParser = require('cookie-parser')

async function bootstrap() {
dotenv.config()

const app = await NestFactory.create(AppModule, { cors: true })

await SwaggerExcludeFilter.setup(app)

app.enableCors({
origin: process.env.URL_FRONT,
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
preflightContinue: false,
optionsSuccessStatus: 204,
credentials: true
})

app.useLogger(new Logger())
app.useGlobalPipes(
new ValidationPipe({
whitelist: true,
forbidNonWhitelisted: true,
transform: true,
disableErrorMessages: false,
exceptionFactory: errors => {
return new BadRequestException(
errors.map(
error =>
`${error.property} errors: ${Object.values(
error.constraints
).join(', ')}`
)
)
}
})
)

app.use(cookieParser())

const PORT = process.env.PORT || 8080
const HOSTNAME = process.env.HOSTNAME || '0.0.0.0'

await app.listen(PORT, HOSTNAME)
}
bootstrap()
Does anyone have an idea ?
5 replies
PPrisma
Created by Guillaume630 on 4/18/2024 in #help-and-questions
Prisma optimization
Hi everyone, i have a postgresql db with a table named Pricing, it contains arouned 35 columns (string and numbers), + and id, an enum and an index for the company_id related, without one to one relation For one specific company_id, it gives me around 1 milllions rows that i have to display on my frontend (100 per 100 with the pagination) My problem is that it lasts at least 1 min to display the data, it's too much, any idea how to improve the db ? Ps: with another company_id related to 10 000 rows, the data appears instantly Thanks
model Pricing {
id Int @id @default(autoincrement())
CATEGORY_FINAL String?
TITLE String?
-- 30 more columns --

likeStatus LikeStatus?

@@index(fields: [company_id, ID_SNOW, ID_CONCURRENT], map: "idx_pricing_company_id")
@@map("pricings")
}
model Pricing {
id Int @id @default(autoincrement())
CATEGORY_FINAL String?
TITLE String?
-- 30 more columns --

likeStatus LikeStatus?

@@index(fields: [company_id, ID_SNOW, ID_CONCURRENT], map: "idx_pricing_company_id")
@@map("pricings")
}
2 replies