Jijin P
03/07/2022, 3:23 AMError: Invalid `prisma_1.default.ads.findMany()` invocation in /usr/src/app/dist/api/offerwall/getClickCampaigns.js:16:50
Attempted to serialize scalar ‘null’ with incompatible type ‘Decimal’ for field points.
at Object.request (/usr/src/app/node_modules/@prisma/client/runtime/index.js:39813:15)
at async PrismaClient._request (/usr/src/app/node_modules/@prisma/client/runtime/index.js:40637:18)
at async getClickCampaigns (/usr/src/app/dist/api/offerwall/getClickCampaigns.js:16:23)
Ian Ray
03/07/2022, 3:36 AMIan Ray
03/07/2022, 3:39 AMnull
in a field that prisma expects to be non-null
Ian Ray
03/07/2022, 3:40 AMDecimal?
would fix your problem?Jijin P
03/07/2022, 4:02 AMmodel ads {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
name String
url String
geo String?
geoExclude Boolean @default(false)
image String?
user_id String @db.Uuid
status Boolean @default(true)
created_at DateTime @default(now()) @db.Timestamptz(6)
updated_at DateTime @default(now()) @db.Timestamptz(6)
description String
credits Decimal @default(0) @db.Decimal
browsers String?
browsers_exclude Boolean @default(false)
featured Boolean? @default(false)
featured_expire DateTime? @db.Date
type String? @db.Uuid
featured_spend Decimal @default(0) @db.Decimal
total_clicks Decimal? @default(0) @db.Decimal
publisher_earned Decimal? @db.Decimal
total_credits Decimal? @default(0) @db.Decimal
ad_type ad_type? @relation(fields: [type], references: [id])
ads_devices ads_devices[]
}
const campaigns = await prisma.ads.findMany({
select: {
id: true,
name: true,
image: true,
description: true,
ad_type: true
},
orderBy: {
featured: 'desc'
},
where: {
status: true,
credits: {
gt: 0
},
AND: [
{
OR: [
{
geo: {
contains: country
},
geoExclude: false
},
{
geo: {
notIn: country
},
geoExclude: true
},
{
geo: ''
}
]
},
{
OR: [
{
ads_devices: { none: {} },
},
{
ads_devices:
{
some:
{
name: {
equals: deviceType
},
from: {
gte: deviceVersion
},
OR: [
{
to: {
lte: deviceVersion
}
},
{
to: {
equals: "current"
}
}
]
}
}
}
]
}]
}
})
Ian Ray
03/07/2022, 4:23 AMpoints
Jijin P
03/07/2022, 4:35 AMIan Ray
03/07/2022, 4:45 AMdecimal
type? Or perhaps, did you not use prisma migrate
to produce the schema in your database? What does the database show for the table schema?Ian Ray
03/07/2022, 4:46 AMnull
here is coming from a point field on ads_devices
or ad_type
Ian Ray
03/07/2022, 4:48 AM\d ads
yields in psql
or pgAdmin
Jijin P
03/07/2022, 4:50 AMIan Ray
03/07/2022, 4:52 AMpoints
on any table in your schema?Jijin P
03/07/2022, 4:52 AMIan Ray
03/07/2022, 4:53 AMselect
Ian Ray
03/07/2022, 4:53 AMad_type
model?
model ad_type {
...
points Decimal? ...
...
}
Jijin P
03/07/2022, 4:53 AMJijin P
03/07/2022, 4:53 AMIan Ray
03/07/2022, 4:54 AMJijin P
03/07/2022, 5:05 AMIan Ray
03/07/2022, 5:54 AMtsconfig.json::compilerOptions.strictNullChecks := true
?Jijin P
03/07/2022, 10:34 AMjanpio