Skip to content

Commit

Permalink
Update 0.4 release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
ellmetha committed Aug 10, 2023
1 parent eb3c9fa commit 9ee75ce
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docs/docs/the-marten-project/release-notes/0.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,31 @@ Crystal 1.7, 1.8, and 1.9.

## New features

### Multi table inheritance

It is now possible to define models that inherit from other concrete models (ie. non-abstract models). In this situation, each model can be used/queried individually and has its own associated database. The framework automatically defines a set of "links" between each model that uses multi table inheritance and its parent models in order to ensure that the relational structure and inheritance hierarchy are maintained.

For example:

```crystal
class Person < Marten::Model
field :id, :big_int, primary_key: true, auto: true
field :first_name, :string, max_size: 100
field :last_name, :string, max_size: 100
end
class Employee < Person
field :company_name, :string, max_size: 100
end
employee = Employee.filter(first_name: "John").first!
employee.first_name # => "John"
```

All the fields defined in the `Person` model can be accessed when interacting with records of the `Employee` model (despite the fact that the data itself is stored in distinct tables).

You can read more about this new kind of model inheritance in [Multi table inheritance](../../models-and-databases/introduction#multi-table-inheritance).

### Schema handler callbacks

Handlers that inherit from the base schema handler - [`Marten::Handlers::Schema`](pathname:///api/dev/Marten/Handlers/Schema.html) - or one of its subclasses (such as [`Marten::Handlers::RecordCreate`](pathname:///api/dev/Marten/Handlers/RecordCreate.html) or [`Marten::Handlers::RecordUpdate`](pathname:///api/dev/Marten/Handlers/RecordUpdate.html)) can now define new kinds of callbacks that allow to easily manipulate the considered [schema](../../schemas/introduction) instance and to define logic to execute before the schema is validated or after (eg. when the schema validation is successful or failed):
Expand Down

0 comments on commit 9ee75ce

Please sign in to comment.