diff --git a/docs/04-get-started/03-working-with-the-database.md b/docs/04-get-started/03-working-with-the-database.md index 1d056603..7f940914 100644 --- a/docs/04-get-started/03-working-with-the-database.md +++ b/docs/04-get-started/03-working-with-the-database.md @@ -96,8 +96,7 @@ class RecipeEndpoint extends Endpoint { // Get all the recipes from the database, sorted by date. return Recipe.db.find( session, - orderBy: (t) => t.date, - orderDescending: true, + orderBy: (t) => t.date.desc(), ); } } @@ -168,8 +167,7 @@ class RecipeEndpoint extends Endpoint { // Get all the recipes from the database, sorted by date. return Recipe.db.find( session, - orderBy: (t) => t.date, - orderDescending: true, + orderBy: (t) => t.date.desc(), ); } } diff --git a/docs/06-concepts/06-database/05-crud.md b/docs/06-concepts/06-database/05-crud.md index 1edd9f0d..b6e5d4c0 100644 --- a/docs/06-concepts/06-database/05-crud.md +++ b/docs/06-concepts/06-database/05-crud.md @@ -207,8 +207,7 @@ var updatedCompanies = await Company.db.updateWhere( session, columnValues: (t) => [t.name('Updated name'), t.address('New address')], where: (t) => t.id > 100, - orderBy: (t) => t.id, - orderDescending: false, + orderBy: (t) => t.id, // or t.id.asc() limit: 10, offset: 5, ); @@ -235,10 +234,9 @@ To batch delete several rows, use the `delete` method. This method also supports ```dart var companiesDeleted = await Company.db.delete( - session, - companies, - orderBy: (t) => t.id, - orderDescending: false, + session, + companies, + orderBy: (t) => t.id, // or t.id.asc() ); ``` @@ -252,10 +250,7 @@ You can also do a [filtered](filter) delete and delete all entries matching a `w var companiesDeleted = await Company.db.deleteWhere( session, where: (t) => t.name.like('%Ltd'), - orderByList: (t) => [ - Order(column: t.name, orderDescending: true), - Order(column: t.id), - ], + orderByList: (t) => [t.name.desc(), t.id.asc()], ); ``` diff --git a/docs/06-concepts/06-database/08-sort.md b/docs/06-concepts/06-database/08-sort.md index 888f45e8..1332d89e 100644 --- a/docs/06-concepts/06-database/08-sort.md +++ b/docs/06-concepts/06-database/08-sort.md @@ -16,22 +16,18 @@ By default the order is set to ascending, this can be changed to descending by s ```dart var companies = await Company.db.find( session, - orderBy: (t) => t.name, - orderDescending: true, + orderBy: (t) => t.name.desc(), ); ``` In the example we fetch all companies and sort them by their name in descending order. -To order by several different columns use `orderByList`, note that this cannot be used in conjunction with `orderBy` and `orderDescending`. +To order by several different columns use `orderByList`, note that this cannot be used in conjunction with `orderBy`. ```dart var companies = await Company.db.find( session, - orderByList: (t) => [ - Order(column: t.name, orderDescending: true), - Order(column: t.id), - ], + orderByList: (t) => [t.name.desc(), t.id.asc()], ); ```