From 6e4afc7d7ddf93753563a2b5935aba4adf1102c5 Mon Sep 17 00:00:00 2001 From: Kacy James Date: Fri, 26 May 2017 14:38:48 -0400 Subject: [PATCH 1/4] Show Minimum Required Functions I think it would be useful to show a complete representation of the model class then go into explaining what does what. Upon reading the documentation, I was under the impression that all I needed to have in order for my model to be valid was: ``` final class Pet: Model { var name: String var age: Int let storage = Storage() init(name: String, age: Int) { self.name = name self.age = age } } ``` --- 2.0/docs/fluent/getting-started.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/2.0/docs/fluent/getting-started.md b/2.0/docs/fluent/getting-started.md index cfab396c..3565dca3 100644 --- a/2.0/docs/fluent/getting-started.md +++ b/2.0/docs/fluent/getting-started.md @@ -18,13 +18,23 @@ final class Pet: Model { var name: String var age: Int let storage = Storage() + + init(row: Row) throws { + name = try row.get("name") + age = try row.get("age") + } init(name: String, age: Int) { self.name = name self.age = age } - - ... + + func makeRow() throws -> Row { + var row = Row() + try row.set("name", name) + try row.set("age", age) + return row + } } ``` From f7a2602fde726b25f7a5e228bf928c36346dd53d Mon Sep 17 00:00:00 2001 From: Kacy James Date: Fri, 26 May 2017 14:43:40 -0400 Subject: [PATCH 2/4] Update getting-started.md --- 2.0/docs/fluent/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2.0/docs/fluent/getting-started.md b/2.0/docs/fluent/getting-started.md index 3565dca3..b4e50d67 100644 --- a/2.0/docs/fluent/getting-started.md +++ b/2.0/docs/fluent/getting-started.md @@ -92,7 +92,7 @@ You can do this by conforming your model to `Preparation`. extension Pet: Preparation { static func prepare(_ database: Database) throws { try database.create(self) { pets in - pets.id(for: self) + pets.id() pets.string("name") pets.int("age") } From 89ecfba1a82acd95d34e06314886ef4b573b75bb Mon Sep 17 00:00:00 2001 From: Kacy James Date: Fri, 26 May 2017 15:04:21 -0400 Subject: [PATCH 3/4] Update getting-started.md --- 2.0/docs/fluent/getting-started.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/2.0/docs/fluent/getting-started.md b/2.0/docs/fluent/getting-started.md index b4e50d67..bd2319a8 100644 --- a/2.0/docs/fluent/getting-started.md +++ b/2.0/docs/fluent/getting-started.md @@ -112,15 +112,15 @@ Here we are creating a simple table that will look like this: ### Add to Droplet -Now you can add your model to the Droplet's prearations so the database is prepared when your application boots. +Now you can add your model to the config's prearations so the database is prepared when your application boots. ```swift import Vapor import FluentProvider -let drop = try Droplet() - -drop.preparations.append(Pet.self) +let config = try Config() +try config.preparations.append(Pet.self) +let drop = try Droplet(config) ... ``` From d5051bab92142435c4d8a538903b0bc3e64036e0 Mon Sep 17 00:00:00 2001 From: Kacy James Date: Fri, 26 May 2017 15:05:15 -0400 Subject: [PATCH 4/4] Update getting-started.md --- 2.0/docs/fluent/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2.0/docs/fluent/getting-started.md b/2.0/docs/fluent/getting-started.md index bd2319a8..40af08a2 100644 --- a/2.0/docs/fluent/getting-started.md +++ b/2.0/docs/fluent/getting-started.md @@ -119,7 +119,7 @@ import Vapor import FluentProvider let config = try Config() -try config.preparations.append(Pet.self) +config.preparations.append(Pet.self) let drop = try Droplet(config) ...