Conversation
|
Is there a PR for upgrading sea-query to 0.25? |
* Custom join condition (SeaQL/sea-orm#793) * Migration does not depend on entity crate * Define integer enum with repr[x] syntax * Document datatype mappings (SeaQL/sea-orm#772) * Cursor pagination (SeaQL/sea-orm#754, SeaQL/sea-orm#822) * (de)serialize custom JSON types (SeaQL/sea-orm#794) * Generate new migration file (SeaQL/sea-orm#656) * Skip generating entity file for specific tables (SeaQL/sea-orm#837) * Generate entity with date time crate option (SeaQL/sea-orm#724) * Drop `SelectTwoMany::one()` method (SeaQL/sea-orm#813) * Datatype mappings of primitives (SeaQL/sea-orm#850, SeaQL/sea-schema#75) * Join with table alias (SeaQL/sea-orm#852) * SQLx logging level (SeaQL/sea-orm#800) * Insert with on conflict (SeaQL/sea-orm#791) * Migrate generate should take file name as argument instead of option (SeaQL/sea-orm#870) * Upgrade docusaurus to 2.0.0-beta.22 * What's new in SeaORM 0.9.0 * Move migration section forward * Rename "Generating Database Schema" section to "Generating SeaQuery Statement" * Fix broken links * Edit * Edit * Edit * Edit Co-authored-by: Chris Tsang <[email protected]>
|
Is there any plan to have cursor in other directions? Like if we want to have |
|
Hey @penso, thanks for asking!! This is exactly what use sea_orm::{entity::*, query::*, tests_cfg::cake};
// Create a cursor that order by `cake`.`id`
let mut cursor = cake::Entity::find().cursor_by(cake::Column::Id);
// Filter paginated result by `cake`.`id` > 1 AND `cake`.`id` < 100
cursor.after(1).before(100);
// Get last 10 rows (order by `cake`.`id` DESC but rows are returned in ascending order)
for cake in cursor.last(10).all(db).await? {
// Do something on cake: cake::Model
} |
|
Wouldn't it be easier to have: so we don't need to convert/reverse the resulted array if we actually want to deliver the last ID first and in descending order? |
|
Hey @penso, I think we have add two additional method - // Get first 10 rows (order by `cake`.`id` ASC but rows are returned in descending order)
for cake in cursor.first_desc(10).all(db).await? {
// Do something on cake: cake::Model
}
// Get last 10 rows (order by `cake`.`id` ASC but rows are returned in descending order)
for cake in cursor.last_desc(10).all(db).await? {
// Do something on cake: cake::Model
} |
|
Is there any drawback to just |
Good question! @penso? |
|
No drawback than I can think of, except the mental thinking. I've done a "manual" cursor this week-end and will try to move to |
|
Please! And let us know your experience after using it :) |
Continue #754
Things to do:
I released the
clear_order_byin sea-query 0.25So the dependency is to upgrade sea-orm to sea-query 0.25.1