This channel is intended for people just starting with the Raku Programming Language ( Logs are available at
Set by lizmat on 8 June 2022.
00:58 hudo__ joined 01:01 hudo_ left
SmokeMachine aruniecrisps: I just rebuilt a small example of Cro + Red as example for Cro-HTTP-Session-Red ( I hope it can help... 01:13
aruniecrisps @SmokeMachine I'm looking at it, I was trying to separate the models into their own separate files but I'm running into errors 04:24
for reference i'm trying to use this file in lib/Models/User.rakumod: use v6.d; use Red:api<2>; unit model User; also is rw; has Int $.id is serial; has Str $.name is column; has @.posts is relationship( *.author-id, :model<Post> ); method active-posts { @!posts.grep: not *.deleted } 04:34
06:40 CIAvash joined 06:41 CIAvash left, CIAvash joined 08:05 CIAvash left 08:06 CIAvash joined 08:07 CIAvash left
SmokeMachine Shouldn’t you be referencing it as Models::User? 15:59
15:59 MasterDuke left
SmokeMachine Or at least `use Models::User` 16:02
And I suppose you will have the same e problem with Post… but you can add `:require<Models::Post>` on your relationship 16:07
If you are writing a blog, I have an example of a blog schema here: 16:15
antononcube Hmm, I am writing 4 blogs, but in neither of them I use databases. 16:25
rcmlz Does anyone has experience running Raku under Nix? I am having trouble installing LibraryMake with zef - an ld error I can not solve. 17:23
aruniecrisps the problem is that i'm not able to reference either module in service.raku 18:59
SmokeMachine Sorry, what do you mean? 19:19
aruniecrisps Ok I'm doing a bit more debugging it looks like even if i do: unit module Models::User; model User is export is table<users> { also is rw; has Int $.id is serial; has Str $.name is column; has @.posts is relationship( *.author-id, :model<Post> ); method active-posts { @!posts.grep: not *.deleted } } add it to META6.json, and then reference it in lib/Models/Post.rakumod like this: use v6.d; use 19:32
Red:api<2>; use Models::User; unit module Models::Post; model PostTag {...} model Post is table<posts> is rw is export { has Int $.id is serial; has $!author-id is referencing( *.id, :model<User> ); has Str $.body is column; has $.author is relationship( *.author-id, :model<User> ); has PostTag is relationship{ .post-id }; has Bool $.deleted is column = False;
has DateTime $.created is column .= now; method tags {>>.tag } } model Tag is table<tags> is export { has Str $.name is id; has PostTag is relationship{ .tag-id }; method posts {>>.post } } model PostTag is table<post_tag> is export { has UInt $.post-id is column{ :id, :references{ .id }, :model-name<Post> } has Str $.tag-id is column{ :id, :references{ .id }, :model-name<Tag> } has
Post $.post is relationship{ .post-id }; has Tag $.tag is relationship{ .tag-id }; } i get this error:
circular module error 19:33
SmokeMachine Could you share the code/repo? 19:39
aruniecrisps @SmokeMachine 19:41
SmokeMachine if you use User on Post and use Post on User it will be a loop... 19:44
aruniecrisps: I have a suggestion that works here: 20:05
that's what I was trying to describe... 20:06
aruniecrisps @SmokeMachine is the :require documented anywhere? 20:13
SmokeMachine it should, but I'm not sure... let me take a look...
20:18 MasterDuke joined
SmokeMachine I think the only place it's mentioned is here: 20:19
I should doc that... would you like to help?
aruniecrisps Yea, in fact I can revamp the documentation site for Red to make it use Docusaurus or Astro: it'll look something like this: 20:21
SmokeMachine but just to explain: if you do `:model<Bla>` it will try to use Bla, but you can change it doing `:model<Bla>, :require<Ble>` that will `use Ble` and use Bla as model... 20:22
aruniecrisps so basically throwing use Model::User or use Model::Post at the top does nothing 20:23
SmokeMachine exactly... and doing that with `:model<...>, :require<...>` does that on runtime, so it will not loop... 20:26
about documentation, I like using Pod6 20:27
aruniecrisps i don't think that's mutually exclusive, you can use Pod6 to generate markdown right? 20:35
SmokeMachine yes...
antononcube More importantly, you can also use Markdown to generate Pod6. 20:37
SmokeMachine that I wouldn't like... 20:38
I like to write Pod6
antononcube Well, still the functionality exists. BTW, I use Pod6 while debugging the corresponding Markdown parser/interpreter. 20:39
SmokeMachine but red tutorials are writen in md... 20:46
and if interested, we also have a #red channel... 20:49
antononcube BTW, still cannot install "Red". I am kind of tired trying to chase all the dependencies and force installs. 20:52
At some point, I might submit a "make a Docker container/image" issue.
SmokeMachine On Red repo there is a docket file for that 20:53
antononcube Yeah, I just saw that. Thanks! 20:54
SmokeMachine 1 of them has no CMD 20:55
aruniecrisps @SmokeMachine yea so what i was thinking is that you could write the docs in markdown which can be fed into docusaurus, I figured Red deserves a landing page unto itself 20:57
SmokeMachine Currently we have this: 20:59
aruniecrisps I'll get back to you with a revamped version of this this week 22:27
also @SmokeMachine also do i have to add every single file manually to META6.json? 22:36
SmokeMachine I usually do (or use Mi6 that does this automatically to you) 22:37 22:40
aruniecrisps how would i use Mi6 to add files automatically for me? 22:43
SmokeMachine Have you seen the report? ( 22:45
When you run `mi6 build` it generates some files, including the META6.json 22:47
aruniecrisps ahhh 22:48
yea i read that
i just wish that cro would automatically run mi6 build on refresh 22:57
SmokeMachine While developing, I usually run Raku with `-Ilib` that ignores META6.json… 22:59
aruniecrisps can you run cro with -Ilib? 23:01
SmokeMachine raku -Ilib <path to cro> … 23:02
Did it work for you? 23:10
aruniecrisps nope 23:20
SmokeMachine What’s the problem?
23:31 swaggboi left
aruniecrisps 23:59