{"body":"use Red;\n\nmodel Post  { ... }\nmodel Photo { ... }\n\nmodel Comment {\n    has UInt  $.id               is serial;\n    has Str   $.body             is column;\n    has UInt  $.commentable-id   is column;\n    has Str   $.commentable-type is column;\n    has Post  $.post             is relationship{ $^a.commentable-id == $^b.id && $^a.commentable-type eq \"post\"  }\n    has Photo $.photo            is relationship{ $^a.commentable-id == $^b.id && $^a.commentable-type eq \"photo\" }\n}\n\nmodel Post {\n    has UInt    $.id is serial;\n    has Str     $.title is unique;\n    has Comment @.comments is relationship{ $^b.commentable-id == $^a.id && $^b.commentable-type eq \"post\" }\n}\n\nmodel Photo {\n    has UInt $.id is serial;\n    has Str  $.path is unique;\n    has Comment @.comments is relationship{ $^b.commentable-id == $^a.id && $^b.commentable-type eq \"photo\" }\n}\n\nred-defaults \"SQLite\";\n\nschema(Comment, Post, Photo).create;\n\nmy $post = Post.^create: :title<bla>, :comments[{ :body<blabla> }];\n\nmy $photo = Photo.^create: :path<ble>;\n$photo.comments.create: :body<bleble>;\n\n.say for Comment.^all.grep: *.post.title eq \"bla\";\n.say for Comment.^all.grep: *.photo.path eq \"ble\";\n\nsay \"comment: { .id }; post: \", .post  for Comment.^all;\nsay \"comment: { .id }; photo: \", .photo for Comment.^all;\n","name":"","extension":"txt","url":"https://www.irccloud.com/pastebin/uv1dvAkV","modified":1754613507,"id":"uv1dvAkV","size":1285,"lines":40,"own_paste":false,"theme":"","date":1754613507}