Getting all items

Fluent provides convenient methods on the Item class so that we can perform a query on the Item collection or table as a whole. To fetch all of the records from the database from a specific table, all we need to do is invoke all of its class, as seen here:

try print(Item.all())

The preceding code will fetch all of the rows from the item's table, convert the table into an array of item type objects and print it in the console.

Get Hands-On Full-Stack Development with Swift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.