Untitled notebook
Section
Welcome to the livebook demo for form_validator. Goal of project is to learn how to model a parent/child relationship in Phoenix LiveView using the ash framework and Ash.Phoenix.Form.
Database model is users
and tweets
There are many tweets per user but only one user per tweet.
Access to User
and Tweet
structures is mediated through Ash framework, which
encapsulates database data at a table level through an Ecto.Schema like module called a “resource”.
Ash.Resources
model both the structure of a database table, (e.g., specifying the “attributes”,
“validations”, or “virtual fields” to be found there) as well as the
actions
or methods that can retrieve and manipulate that data, and persist it to the database.
Ash.Resources
are by convention placed in directory like ./lib/resource/
.
Typing something like Ash.Resource.Info.attributes(User)
will show you the fields defined for resource User,
list the fields defined to ash
in the “res”).
The schema for each User
and Tweet
, along with the validations, relationships,
and “virtual fields” (called aggregates
or calculations
) and actions
or methods that
! This livebook allows you to connect directly to an instance of a demo application that serves as a playground and live demonstration of Ash features.
Install livebook:
mix escript.install hex livebook
If you are running asdf
you may need to:
asdf reshim elixir
Start the livebook server from inside the repo:
livebook server
Visit http://localhost:8080
Copy the token from the output of the livebook server
command into the livebook page.
Connect the livebook instance to the repo by changing the Runtime settings in the livebook page to use Mix standalone
, and select the repo.
This will start a new local node in the context of a Mix project. This way all your code and dependencies will be available within the notebook.