Member-only story

Database concepts in Aqueduct

Suragch
3 min readDec 9, 2019

--

This article is Part 9 of a longer course on Server Side Dart as a backend for Flutter apps. You can find the full playlist on YouTube here.

ORM

Aqueduct uses Object Relational Mapping (ORM) to conveniently store your Dart model objects in a database. It uses PostgreSQL (an open source object relational database) for the database server.

If that sounded confusing, let’s look at how this is useful. In mobile development you are often working with SQLite. With this relational database, if you want to store an object, you generally have to take the basic data types (string, int, bool, etc) from your object and save them as separate column values in a row of a table. When you want to get the object back, you get the row and then build your object based on the column values. Having an ORM takes care of all this boilerplate code. All you need to do is tell Aqueduct, here is my object, save it for me. Or, I need such-and-such an object, go get it for me. There is no need worry about converting back and forth.

How Aqueduct manages data

For objects that you want to store in the database, you create subclasses of ManagedObject. These represent database tables where the rows are instances of the object and the columns are properties of the object. You might have many ManagedObjects in a project, the same way you might have many tables in a database.

--

--

Suragch
Suragch

Written by Suragch

Flutter and Dart developer. Twitter: @suragch1, Email: suragch@suragch.dev

No responses yet