OxL Справочник OxL
РусскийEnglish

method Query.count

Number of matching rows, ignoring skip and take.

Example:

oxl✓ проверяется в CI
use std.orm { Db }

@table("items")
data Item {
  @pk id: i64
  price: i64
}

fn main() io, db {
  let db = Db.open("sqlite::memory:")!
  db.Item.insert(Item{ id: 1, price: 3 })
  db.Item.insert(Item{ id: 2, price: 9 })
  print("{db.Item.query().sqlWhere("price > 5").count()}")
  db.close()
}
Вывод
1
pub(api) fn count() -> i64  db

Сложность. O(1) to O(rows) in the database.

С версии. 1.0.0-beta

Возвращает

i64

Эффекты

db

Определено в: std/orm/orm.oxl:979

См. также