# Pastebin TROJKDjA raku -I. -MRed -e ' model Person {...} model Post is rw { has Int $.id is serial; has Int $!author-id is referencing( *.id, :model ); has Str $.title is column{ :unique }; has Str $.body is column; has Person $.author is relationship{ .author-id }; has Bool $.deleted is column = False; has DateTime $.created is column .= now; has Set $.tags is column{ :type, :deflate{ .keys.join: "," }, :inflate{ set(.split: ",") } } = set(); method delete { $!deleted = True; self.^save } } model Person is rw { has Int $.id is serial; has Str $.name is column; has Post @.posts is relationship{ .author-id }; method active-posts { @!posts.grep: not *.deleted } } my $*RED-DEBUG = True; my $*RED-DB = database("SQLite"); say "✓ Creating tables for Person and Post"; Person.^create-table; Post.^create-table; say "✓ Creating a Person"; my $p = Person.^create: :name; $p.posts.create: :title, :body; .say for Post.^all ' ✓ Creating tables for Person and Post SQL : CREATE TABLE person( id integer NOT NULL primary key AUTOINCREMENT, name varchar(255) NOT NULL ) BIND: [] SQL : CREATE TABLE post( id integer NOT NULL primary key AUTOINCREMENT, author_id integer NULL references person(id), title varchar(255) NOT NULL , body varchar(255) NOT NULL , deleted integer NOT NULL , created varchar(255) NOT NULL , tags varchar(255) NOT NULL , UNIQUE (title) ) BIND: [] ✓ Creating a Person SQL : INSERT INTO person( name ) VALUES( ? ) BIND: ["Fernando"] SQL : SELECT person.id , person.name FROM person WHERE _rowid_ = last_insert_rowid() LIMIT 1 BIND: [] SQL : SELECT person.id , person.name FROM person WHERE person.id = 1 LIMIT 1 BIND: [] SQL : INSERT INTO post( created, body, title, author_id, tags, deleted ) VALUES( ?, ?, ?, ?, ?, ? ) BIND: ["2020-01-16T14:44:38.448989Z", "Ble", "Bla", 1, "", Bool::False] SQL : SELECT post.id , post.author_id as "author-id", post.title , post.body , post.deleted , post.created , post.tags FROM post WHERE _rowid_ = last_insert_rowid() LIMIT 1 BIND: [] SQL : SELECT post.id , post.author_id as "author-id", post.title , post.body , post.deleted , post.created , post.tags FROM post WHERE post.id = 1 LIMIT 1 BIND: [] SQL : SELECT post.id , post.author_id as "author-id", post.title , post.body , post.deleted , post.created , post.tags FROM post BIND: [] Post.new(id => 1, title => "Bla", body => "Ble", deleted => Bool::False, created => DateTime.new(2020,1,16,14,44,38.448989), tags => Set.new(""))