@@ -214,7 +214,7 @@ extension Book.Kind: DatabaseValueConvertible { }
214214
215215// Fetch all novels
216216let novels = try dbQueue.read { db in
217- try Book.filter ( Column ( " kind" ) == Book.Kind .novel ) .fetchAll (db)
217+ try Book.filter { $0 . kind == Book.Kind .novel } .fetchAll (db)
218218}
219219```
220220
@@ -330,12 +330,12 @@ try dbQueue.read { db in
330330 // Fetch all authors, ordered by name,
331331 // in a localized case-insensitive fashion
332332 let sortedAuthors: [Author] = try Author.all ()
333- .order (Author. Columns . name .collating (.localizedCaseInsensitiveCompare ))
333+ .order { $0 . name .collating (.localizedCaseInsensitiveCompare ) }
334334 .fetchAll (db)
335335
336336 // Count French authors
337337 let frenchAuthorCount: Int = try Author.all ()
338- .filter (Author. Columns . countryCode == " FR" )
338+ .filter { $0 . countryCode == " FR" }
339339 .fetchCount (db)
340340}
341341```
@@ -351,27 +351,25 @@ Define those methods in extensions of the ``DerivableRequest`` protocol, as belo
351351extension DerivableRequest< Author> {
352352 /// Order authors by name, in a localized case-insensitive fashion
353353 func orderByName () -> Self {
354- let name = Author.Columns .name
355- return order (name.collating (.localizedCaseInsensitiveCompare ))
354+ order { $0 .name .collating (.localizedCaseInsensitiveCompare ) }
356355 }
357356
358357 /// Filters authors from a country
359358 func filter (countryCode : String ) -> Self {
360- filter (Author. Columns . countryCode == countryCode)
359+ filter { $0 . countryCode == countryCode }
361360 }
362361}
363362
364363// Book requests
365364extension DerivableRequest< Book> {
366365 /// Order books by title, in a localized case-insensitive fashion
367366 func orderByTitle () -> Self {
368- let title = Book.Columns .title
369- return order (title.collating (.localizedCaseInsensitiveCompare ))
367+ order { $0 .title .collating (.localizedCaseInsensitiveCompare ) }
370368 }
371369
372370 /// Filters books by kind
373371 func filter (kind : Book.Kind) -> Self {
374- filter (Book. Columns . kind == kind)
372+ filter { $0 . kind == kind }
375373 }
376374}
377375```
@@ -397,7 +395,7 @@ Extensions to the `DerivableRequest` protocol can not change the type of request
397395extension QueryInterfaceRequest< Author> {
398396 // Selects authors' name
399397 func selectName () -> QueryInterfaceRequest<String > {
400- select (Author. Columns . name )
398+ select { $0 . name }
401399 }
402400}
403401
0 commit comments