计数
count
返回符合一组筛选条件的记录数量。
示例使用以下模式
model Post {
id String @id @default(cuid())
title String
content String
}
use prisma::comment;
// Passing no filters will count all records
let all_count: usize = client
.comment()
.count(vec![])
.exec()
.await?;
// Number of records whose title starts with "Post"
let filtered_count: usize = client
.comment()
.count(vec![comment::title::starts_with("Post".to_string())])
.exec()
.await?;