SkillAgentSearch skills...

DVDRental

Demo app using Direct to SwiftUI on top of a Sakila Database

Install / Use

/learn @DirectToSwift/DVDRental
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

<h2>Direct to SwiftUI: DVDRental Example <img src="http://zeezide.com/img/d2s/D2SIcon.svg" align="right" width="128" height="128" /> </h2>

Swift5.1 macOS15 iOS13 watchOS6 Travis

Going fully declarative: Direct to SwiftUI.

Direct to SwiftUI is an adaption of an old WebObjects technology called Direct to Web. This time for Apple's new framework: SwiftUI. Instant CRUD apps, configurable using a declarative rule system, yet fully integrated with SwiftUI.

There is a blog entry explaining how to use this: Introducing Direct to SwiftUI.

This repo is a Direct to SwiftUI example application. It connects against database instances with the Sakila example database, aka "DVDRental".

It is preconfigured to use the PostgresClientKit adaptor, but should work w/ any ZeeQL adaptor, e.g. SQLite. PG is recommended because the PostgreSQL SQL catalog has high fidelity (e.g. SQLite doesn't even have a Date type). This allows D2S to provide a pretty good default ORM mapping schema from just the catalog.

The sample contains targets to build iOS, watchOS and macOS applications.

There is a version of this using CoreData instead of ZeeQL: DVDRentalCoreData.

What it looks like

Watch

<p float="left" valign="top"> <img width="200" src="http://www.alwaysrightinstitute.com/images/d2s/watchos-screenshots/01-homepage.png?v=2"> <img width="200" src="http://www.alwaysrightinstitute.com/images/d2s/watchos-screenshots/02-customers.png?v=2"> <img width="200" src="http://www.alwaysrightinstitute.com/images/d2s/watchos-screenshots/03-customer.png?v=2"> <img width="200" src="http://www.alwaysrightinstitute.com/images/d2s/watchos-screenshots/04-movies.png?v=2"> </p>

Phone

<p float="left" valign="top"> <img width="320" src="http://www.alwaysrightinstitute.com/images/d2s/limited-entities.png"> <img width="320" src="http://www.alwaysrightinstitute.com/images/d2s/list-customer-default.png"> </p>

macOS

Still too ugly to show, but works in a very restricted way ;-)

Setting up PostgreSQL

Using Homebrew

brew install PostgreSQL
brew services start postgresql # start at computer start
createuser -s postgres

Using Postgres.app

Download and install Postgres.app, a nice UI wrapper to manage PostgreSQL databases.

Loading the dvdrental DB

curl -o /tmp/dvdrental.zip \
  http://www.postgresqltutorial.com/wp-content/uploads/2019/05/dvdrental.zip
mkdir -p /tmp/dvdrental && cd /tmp/dvdrental
tar zxf /tmp/dvdrental.zip
tar xf  /tmp/dvdrental.tar # crazy, right?
createdb dvdrental
pg_restore -h localhost -U postgres -d dvdrental .
$ psql -h localhost -U postgres dvdrental
psql (11.4)
Type "help" for help.

dvdrental=# \dt
             List of relations
 Schema |     Name      | Type  |  Owner   
--------+---------------+-------+----------
 public | actor         | table | postgres
 public | address       | table | postgres
 public | category      | table | postgres
 public | city          | table | postgres
 public | country       | table | postgres
 public | customer      | table | postgres
 public | film          | table | postgres
 public | film_actor    | table | postgres
 public | film_category | table | postgres
 public | inventory     | table | postgres
 public | language      | table | postgres
 public | payment       | table | postgres
 public | rental        | table | postgres
 public | staff         | table | postgres
 public | store         | table | postgres
(15 rows)

Make a Backup Copy

To create a backup copy of your database, run:

CREATE DATABASE dvdrental_org TEMPLATE dvdrental;

Setting up SQLite dvdrental (Sakila)

cd /tmp
wget https://raw.githubusercontent.com/jOOQ/jOOQ/master/jOOQ-examples/Sakila/sqlite-sakila-db/sqlite-sakila-schema.sql
wget https://raw.githubusercontent.com/jOOQ/jOOQ/master/jOOQ-examples/Sakila/sqlite-sakila-db/sqlite-sakila-insert-data.sql
sqlite3 dvdrental.sqlite3 < sqlite-sakila-schema.sql
sqlite3 dvdrental.sqlite3 < sqlite-sakila-insert-data.sql
sqlite3 dvdrental.sqlite3
sqlite> .tables
actor                   film                    payment               
address                 film_actor              rental                
category                film_category           sales_by_film_category
city                    film_list               sales_by_store        
country                 film_text               staff                 
customer                inventory               staff_list            
customer_list           language                store                 

ER Diagram

<img src="https://www.jooq.org/img/sakila.png">

Who

Brought to you by The Always Right Institute and ZeeZide. We like feedback, GitHub stars, cool contract work, presumably any form of praise you can think of.

View on GitHub
GitHub Stars4
CategoryData
Updated11mo ago
Forks0

Languages

Swift

Security Score

67/100

Audited on Apr 28, 2025

No findings