P
Prisma5mo ago
Nik

Query fields on an object

Given my prisma schema:
enum PointType {
Point
}
type Point {
type PointType
coordinates Float[] //manually index as: '2dsphere'
}
type FeatureProperties {
id String
unit String
number String
street String
city String
district String
region String
postcode String
hash String
}
enum FeatureType {
Feature
}
model Feature {
id String @id @default(auto()) @map("_id") @db.ObjectId

type FeatureType
county County @relation(fields: [county_id], references: [id])
county_id String @db.ObjectId
properties FeatureProperties
geometry Point

zip_boundary ZipBoundary @relation(fields: [zip_boundary_id], references: [id])
zip_boundary_id String @db.ObjectId

houses House[]

created_at DateTime @default(now())
updated_at DateTime @updatedAt
@@map("features")
}
enum PointType {
Point
}
type Point {
type PointType
coordinates Float[] //manually index as: '2dsphere'
}
type FeatureProperties {
id String
unit String
number String
street String
city String
district String
region String
postcode String
hash String
}
enum FeatureType {
Feature
}
model Feature {
id String @id @default(auto()) @map("_id") @db.ObjectId

type FeatureType
county County @relation(fields: [county_id], references: [id])
county_id String @db.ObjectId
properties FeatureProperties
geometry Point

zip_boundary ZipBoundary @relation(fields: [zip_boundary_id], references: [id])
zip_boundary_id String @db.ObjectId

houses House[]

created_at DateTime @default(now())
updated_at DateTime @updatedAt
@@map("features")
}
I am looking to make a query on the zip code, quite simple requirement. However, Prisma isn't allowing this to happen: let dominantZipAddresses = await database.feature.findMany({where:{ properties:{postcode: dominantZip} }}); This fails because it expects id, unit, etc. to also be included with the postcode. But for a query that makes no sense. Without defaulting to raw queries, how can I accomplish this?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server