Skip to content

Commit

Permalink
Remove mention of delete from operations guide. Rename query guide to…
Browse files Browse the repository at this point in the history
… include mention of deleting. Also caught a few missed updates for the guides. (#107)
  • Loading branch information
jwoertink committed Aug 14, 2019
1 parent 296f470 commit 4e8304c
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/actions/guides/database/database_setup.cr
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Guides::Database::DatabaseSetup < GuideAction
data you use in development, or even special data your application expects to exist in production.
By default, Lucky generates two tasks in your app's `tasks/` folder. `Db::CreateRequiredSeeds`,
and `Db::CreateSampleSeeds`. You can use [Boxes](#{Guides::Database::Testing.path}) or [Operations](#{Guides::Database::ValidatingSavingDeleting.path}) to create the data.
and `Db::CreateSampleSeeds`. You can use [Boxes](#{Guides::Database::Testing.path}) or [Operations](#{Guides::Database::ValidatingSaving.path}) to create the data.
### Required Seeds
Expand Down
6 changes: 3 additions & 3 deletions src/actions/guides/database/intro_to_avram_and_orms.cr
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Guides::Database::IntroToAvramAndORMs < GuideAction
Lucky will create a `User::BaseQuery` class for you, and your `UserQuery` object will inherit from that.
(e.g. `UserQuery < User::BaseQuery`).
[Learn more about queries](#{Guides::Database::Querying.path})
[Learn more about queries](#{Guides::Database::QueryingDeleting.path})
## Operations
Expand All @@ -70,7 +70,7 @@ class Guides::Database::IntroToAvramAndORMs < GuideAction
The naming convention for operations is to use an action of what this object does like save a user record.
(e.g. `User` model, `SaveUser` operation).
[Learn more about operations](#{Guides::Database::ValidatingSavingDeleting.path})
[Learn more about operations](#{Guides::Database::ValidatingSaving.path})
## Migrations
Expand Down Expand Up @@ -121,7 +121,7 @@ class Guides::Database::IntroToAvramAndORMs < GuideAction
```
* Place migrations (if necessary) in `db/migrations/`.
* Boxes, and Queries are specific to Avram Models, but you can still use [Basic Operations](#{Guides::Database::ValidatingSavingDeleting.path}).
* Boxes, and Queries are specific to Avram Models, but you can still use [Basic Operations](#{Guides::Database::ValidatingSaving.path}).
> If your app doesn't need a database, you should still set the `Avram::Database` configure setting to
> some non-empty string. Avram Operations can still be quite useful for things like contact forms,
Expand Down
6 changes: 3 additions & 3 deletions src/actions/guides/database/models.cr
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class Guides::Database::Models < GuideAction
`User` model, you would run `lucky gen.model User`. Running this will generate a few files for you.
* [User model](##{ANCHOR_SETTING_UP_A_MODEL}) - Located in `./src/models/user.cr`
* [SaveUser Operation](#{Guides::Database::ValidatingSavingDeleting.path}) - Located in `./src/operations/save_user.cr`
* [User query](#{Guides::Database::Querying.path}) - Located in `./src/queries/user_query.cr`
* [SaveUser Operation](#{Guides::Database::ValidatingSaving.path}) - Located in `./src/operations/save_user.cr`
* [User query](#{Guides::Database::QueryingDeleting.path}) - Located in `./src/queries/user_query.cr`
* [User migration](#{Guides::Database::Migrations.path}) - Location in `./db/migrations/#{Time.utc.to_s("%Y%m%d%H%I%S")}_create_users.cr`
#{permalink(ANCHOR_SETTING_UP_A_MODEL)}
Expand Down Expand Up @@ -342,7 +342,7 @@ class Guides::Database::Models < GuideAction
### Preloading polymorphic associations
Since the polymorphic associations are just regular `belongs_to` associations with some sweet
helper methods, all of the [preloading](#{Guides::Database::Querying.path(anchor: Guides::Database::Querying::ANCHOR_PRELOADING)}) still exists.
helper methods, all of the [preloading](#{Guides::Database::QueryingDeleting.path(anchor: Guides::Database::QueryingDeleting::ANCHOR_PRELOADING)}) still exists.
```crystal
comment = CommentQuery.new.preload_commentable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class Guides::Database::Querying < GuideAction
class Guides::Database::QueryingDeleting < GuideAction
ANCHOR_PRELOADING = "perma-preloading"
guide_route "/database/querying"
guide_route "/database/querying-deleting"

def self.title
"Querying the Database"
"Querying and Deleting records"
end

def markdown
Expand Down Expand Up @@ -553,15 +553,21 @@ class Guides::Database::Querying < GuideAction
### Truncate
If you need to just delete every record in the entire table, you can use `truncate`.
If you need to delete every record in the entire table, you can use `truncate`.
`TRUNCATE TABLE users`
```crystal
UserQuery.truncate
```
> This method is not chainable, and may be renamed in the future.
You can also truncate your entire database by calling `truncate` on your database class.
```crystal
AppDatabase.truncate
```
> This method is great for tests; horrible for production. Also note this method is not chainable.
## Complex Queries
Expand Down
2 changes: 1 addition & 1 deletion src/actions/guides/database/raw-sql.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Guides::Database::RawSql < GuideAction
which we will later map to classes that can be easily used in our app.
```crystal
posts_result_set = Avram::Database.run do |db|
posts_result_set = AppDatabase.run do |db|
db.query_all "SELECT * FROM posts;"
end
```
Expand Down
2 changes: 1 addition & 1 deletion src/actions/guides/database/testing.cr
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Guides::Database::Testing < GuideAction
## Saving records
As shown previously, a Box has a `create` method which saves the record to your database. A Box is
essentially a fancy wrapper around [SaveOperation](#{Guides::Database::ValidatingSavingDeleting.path}).
essentially a fancy wrapper around [SaveOperation](#{Guides::Database::ValidatingSaving.path}).
Boxes give you access to two helpful class methods `create` and `create_pair`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class Guides::Database::ValidatingSavingDeleting < GuideAction
class Guides::Database::ValidatingSaving < GuideAction
ANCHOR_USING_WITH_HTML_FORMS = "perma-using-with-html-forms"
guide_route "/database/validating-saving-deleting"
guide_route "/database/validating-saving"

def self.title
"Validating, Saving, and Deleting"
"Validating and Saving"
end

def markdown
Expand All @@ -15,7 +15,7 @@ class Guides::Database::ValidatingSavingDeleting < GuideAction
filled. `{ModelName}::SaveOperation` automatically defines an attribute for each model field.
We’ll be using the migration and model from the [Querying
guide](#{Guides::Database::Querying.path}). Once you have that set up, let’s set
guide](#{Guides::Database::QueryingDeleting.path}). Once you have that set up, let’s set
up a save operation:
```crystal
Expand Down
2 changes: 1 addition & 1 deletion src/actions/guides/frontend/rendering_html.cr
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class Guides::Frontend::RenderingHtml < GuideAction
### Rendering HTML forms
There are some helpers for rendering HTML forms. For more info see the [saving
data with forms](#{Guides::Database::ValidatingSavingDeleting.path(anchor: Guides::Database::ValidatingSavingDeleting::ANCHOR_USING_WITH_HTML_FORMS)}) guide.
data with operations](#{Guides::Database::ValidatingSaving.path(anchor: Guides::Database::ValidatingSaving::ANCHOR_USING_WITH_HTML_FORMS)}) guide.
### Other special helpers
Expand Down
6 changes: 3 additions & 3 deletions src/actions/guides/getting-started/why_lucky.cr
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class Guides::GettingStarted::WhyLucky < GuideAction
## Spend less time writing tests and debugging
[Type safe database queries](#{Guides::Database::Querying.path}), [rock solid
[Type safe database queries](#{Guides::Database::QueryingDeleting.path}), [rock solid
routing](#{Guides::HttpAndRouting::RoutingAndParams.path}), [type safe forms and
validations](#{Guides::Database::ValidatingSavingDeleting.path}), and more. This is how Lucky helps you
validations](#{Guides::Database::ValidatingSaving.path}), and more. This is how Lucky helps you
find errors before they reach your customers, write fewer tests, and spend less
time fixing embarrassing bugs.
Expand Down Expand Up @@ -75,7 +75,7 @@ class Guides::GettingStarted::WhyLucky < GuideAction
[router]: #{Guides::HttpAndRouting::RoutingAndParams.path}
[HTML]: #{Guides::Frontend::RenderingHtml.path}
[actions]: #{Guides::HttpAndRouting::RoutingAndParams.path}
[forms]: #{Guides::Database::ValidatingSavingDeleting.path}
[operations]: #{Guides::Database::ValidatingSaving.path}
## Catch missing assets at compile time
Expand Down
6 changes: 4 additions & 2 deletions src/actions/guides/redirect.cr
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class Guides::Redirect < BrowserAction
"database-migrations" => Guides::Database::Migrations,
"actions-and-routing" => Guides::HttpAndRouting::RoutingAndParams,
"rendering-html" => Guides::Frontend::RenderingHtml,
"querying-the-database" => Guides::Database::Querying,
"querying-the-database" => Guides::Database::QueryingDeleting,
"custom-queries" => Guides::Database::RawSql,
"saving-with-forms" => Guides::Database::ValidatingSavingDeleting,
"saving-with-forms" => Guides::Database::ValidatingSaving,
"asset-handling" => Guides::Frontend::AssetHandling,
"tasks" => Guides::CommandLineTasks::BuiltIn,
"logging-and-error-handling" => Guides::Logging,
Expand All @@ -19,6 +19,8 @@ class Guides::Redirect < BrowserAction
"sending-emails" => Guides::Emails::SendingEmailsWithCarbon,
"authentication" => Guides::Authentication::Show,
"deploying-heroku" => Guides::Deploying::Heroku,
"database/validating-saving-deleting" => Guides::Database::ValidatingSaving,
"database/querying" => Guides::Database::QueryingDeleting
}

get "/guides/:guide_path" do
Expand Down
4 changes: 2 additions & 2 deletions src/components/guides/sidebar.cr
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class Guides::Sidebar < BaseComponent
Guides::Database::DatabaseSetup,
Guides::Database::Migrations,
Guides::Database::Models,
Guides::Database::Querying,
Guides::Database::ValidatingSavingDeleting,
Guides::Database::QueryingDeleting,
Guides::Database::ValidatingSaving,
Guides::Database::RawSql,
Guides::Database::Testing,
] of GuideAction.class),
Expand Down

0 comments on commit 4e8304c

Please sign in to comment.