add offset and limit (#351)

* add offset and limit

* move offset&limit to QuerySelect
This commit is contained in:
lz1998 2021-12-03 01:12:49 +08:00 committed by GitHub
parent cc4904993a
commit 273dc0dd1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,6 +71,40 @@ pub trait QuerySelect: Sized {
self
}
/// Add an offset expression
/// ```
/// use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};
///
/// assert_eq!(
/// cake::Entity::find()
/// .offset(10)
/// .build(DbBackend::MySql)
/// .to_string(),
/// "SELECT `cake`.`id`, `cake`.`name` FROM `cake` OFFSET 10"
/// );
/// ```
fn offset(mut self, offset: u64) -> Self {
self.query().offset(offset);
self
}
/// Add a limit expression
/// ```
/// use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};
///
/// assert_eq!(
/// cake::Entity::find()
/// .limit(10)
/// .build(DbBackend::MySql)
/// .to_string(),
/// "SELECT `cake`.`id`, `cake`.`name` FROM `cake` LIMIT 10"
/// );
/// ```
fn limit(mut self, limit: u64) -> Self {
self.query().limit(limit);
self
}
/// Add a group by column
/// ```
/// use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};