Server Side Swift with Vapor: Parent-Child Relations | Ray Wenderlich

In this screencast, you'll learn how to set up parent / child relationships between database tables in Vapor and Fluent.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5025-server-side-swift-with-vapor-parent-child-relations

These jokes keep getting better and better!
Thanks for another fab tutorial.

Commands

vapor build
vapor run prepare --revert

SQL

psql
\d+ acronyms
select * from acronyms;

Thanks Alex, and thanks again for posting the commands & SQL! :]

1 Like

Thanks for tutorial! I guess next tutorial will be authentication?)

Me too desperately waiting for authentication tutorial. :sunglasses:

I’m having issues with the Parent Id (Project) not populating itself in my equivalent of my addAcronym function.

DatabaseError.invalidSQL("ERROR: null value in column \"project_id\" violates not-null constraint\nDETAIL: Failing row contains (1, new channel, null).\n").

Can anyone explain?

Thanks

Great Screencast.

Is there a way of setting your routes up so that you can be more “RESTful” with the relationships?

IE: POST http://xxxx/user/1/acyronm ?

I am struggling with this myself atm.

Loving the Vapor tutorials, please keep up the great work. Could I please request covering authentication and authorisation soon? That would mostly round off an amazing set of Vapor tutorials for me.

P.S. would be great if said video could include securing the passwords with basic hashing.

I’ve mostly got it working, but struggling a little with not re-hashing the already hashed password when it comes back out of the database. And my register method still contains the default “Register not supported” badRequest logic :frowning: