Hi, I just want to get the total number of posts i...
# orm-help
i
Hi, I just want to get the total number of posts in my post table. I tried :
_prisma.post.count_()
But it says: Invalid 
prisma.post.aggregate()
 invocation:\n\n\n  Failed to validate the query: 
Field does not exist on enclosing type.
 at `Query.aggregatepost.AggregatePost._count Any solution for it? Thanking in advance :)
r
@Ibad Shaikh 👋 What version of Prisma are you on?
i
"@prisma/client": "^2.30.3", "prisma": "^2.30.3"
r
Couldn't reproduce this on this version. Could you share your schema and query?
i
model post { id Int @id @default(autoincrement()) caption String? img_url String? link String? created_at DateTime? @default(now()) is_active Boolean? gender String? clicks Int? impressions Int? category_id Int? user_id Int? age String? country String? is_featured Boolean? modified_at DateTime? expires_at DateTime? is_expired Boolean @default(true) ratio String? coins Int? category category? @relation(fields: [category_id], references: [id]) user user? @relation(fields: [user_id], references: [id]) bot_comments bot_comments[] bot_ratings bot_ratings[] comment comment[] favorite favorite[] notification notification[] rating rating[] report report[] advise advise[] voucher voucher? @@index([category_id], name: "IDX_5A8A6C8D12469DE2") @@index([user_id], name: "IDX_5A8A6C8DA76ED395") }
r
Just tried on the above schema (without relations) and it works fine.
i
I unable to figure out why its giving error : PrismaClientKnownRequestError3 [PrismaClientKnownRequestError]: Invalid
prisma.post.aggregate()
invocation: Failed to validate the query:
Field does not exist on enclosing type.
at
Query.aggregatepost.AggregatePost._count
at cb (F:\All Works\backend\node_modules\@prisma\client\runtime\index.js3649417) at processTicksAndRejections (internal/process/task_queues.js935) at async main (file///F/All%20Work/backend/prisma/seed.js213) { code: 'P2009', clientVersion: '2.30.3', meta: { query_validation_error: 'Field does not exist on enclosing type.', query_position: 'Query.aggregatepost.AggregatePost._count' } }
Is there any issue due to relations? Despite all other operations related to this post model are working fine!
r
I would suggest creating a bug report here with the reproduction steps so that we can look into this.
i
Thanks @Ryan