Is there a way create another Model from inside the route handler of a specific model?
I think I’m most of the way there. Tell me if I’m on the right track as I know you can probably return a tuple of models Future<(User, UserDetails, MatchMakingData)>
and when I save use I can probably access the user.id once it’s done saving by:
let savedUser = try user.save(on: request).flatMap(to: User.self) { user in … }
While inside the closure I can’t seem to figure out how to create a UserDetails, or MatchMaking Model to assign the newly created user.id to it immediately.
@yungdai have a look at the current WebsiteController for the book:
That shows you how to create models when others are created. Just a note, you should only really do this with web clients - with REST these should probably be separate requests
Thank you for the excellent hint, however I believe that’s for chapter 14 of your book which isn’t done yet. I’ll be anxiously waiting for those releases