Skip to content

Commit

Permalink
Merge branch 'crystal-v0.30.0' of github.com:amberframework/granite i…
Browse files Browse the repository at this point in the history
…nto crystal-v0.30.0
  • Loading branch information
drujensen committed Aug 3, 2019
2 parents a3f1b35 + 570e750 commit 88815fb
Show file tree
Hide file tree
Showing 53 changed files with 1,136 additions and 1,449 deletions.
7 changes: 4 additions & 3 deletions docs/callbacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ Here is an example:
require "granite/adapter/pg"
class Post < Granite::Base
adapter pg
connection pg
before_save :upcase_title
field title : String
field content : String
column id : Int64, primary: true
column title : String
column content : String
timestamps
def upcase_title
Expand Down
2 changes: 1 addition & 1 deletion docs/crud.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Combination of object creation and insertion into database.

```
```crystal
Post.create(name: "Granite Rocks!", body: "Check this out.") # Set attributes and call save
Post.create!(name: "Granite Rocks!", body: "Check this out.") # Set attributes and call save!. Will throw an exception when the save failed
```
Expand Down
14 changes: 7 additions & 7 deletions docs/imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

## Import

**Note: Imports do not trigger callbacks automatically. See [Running Callbacks](#running-callbacks).**
> **Note:** Imports do not trigger callbacks automatically. See [Running Callbacks](#running-callbacks).
Each model has an `import` class level method to import an array of models in one bulk insert statement.
Each model has an `.import` method that will save an array of models in one bulk insert statement.
```Crystal
models = [
Model.new(id: 1, name: "Fred", age: 14),
Expand Down Expand Up @@ -86,11 +86,11 @@ Since the `import` method runs on the class level, callbacks are not triggered a
require "uuid"
class Item < Granite::Base
adapter mysql
table_name items
connection mysql
table items
primary item_id : String, auto: false
field item_name : String
column item_id : String, primary: true, auto: false
column item_name : String
before_create :generate_uuid
Expand Down Expand Up @@ -122,4 +122,4 @@ Since the `import` method runs on the class level, callbacks are not triggered a
item.save
```

**Note: Manually running your callbacks is mainly aimed at bulk imports. Running them before a normal `.save`, for example, would run your callbacks twice.**
> **Note:** Manually running your callbacks is mainly aimed at bulk imports. Running them before a normal `.save`, for example, would run your callbacks twice.
184 changes: 0 additions & 184 deletions docs/json_support.md

This file was deleted.

8 changes: 5 additions & 3 deletions docs/migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ Provides `drop`, `create` and `drop_and_create` methods

```crystal
class User < Granite::Base
adapter mysql
field name : String
connection mysql
column id : Int64, primary: true
column name : String
end
User.migrator.drop_and_create
Expand All @@ -19,7 +21,7 @@ Provides `drop`, `create` and `drop_and_create` methods
```
## Database Migrations with micrate

If you're using Granite ORM to query your data you likely want to manage your database schema as well. Migrations are a great way to do that, so let's take a look at [micrate](https://github.com/juanedi/micrate), a project to manage migrations. We'll use it as a dependency instead of a pre-build binary.
If you're using Granite to query your data, you likely want to manage your database schema as well. Migrations are a great way to do that, so let's take a look at [micrate](https://github.com/juanedi/micrate), a project to manage migrations. We'll use it as a dependency instead of a pre-build binary.

### Install

Expand Down
Loading

0 comments on commit 88815fb

Please sign in to comment.