Implement a forum data model in Elixir

Building an Elixir data layer for our Forum with Ecto

Building an Elixir data layer for our Forum with Ecto.

We're going to build a Forum GraphQL API, but the API is not our application - it's just an interface to our application. We'll build the core business logic in a firestorm_data application inside of an umbrella.

We can start by building a new umbrella project:

mix new firestorm --umbrella cd firestorm

We have a new umbrella app - let's create the firestorm_data app to hold our business logic and database interface:

cd apps mix new firestorm_data --sup cd firestorm_data

Let's review the Forum data model:

  • A Forum has many Categories
  • A Category has many Threads
  • A Thread has many Posts
  • A Post belongs to a Thread
  • A Post belongs to a User

We'll begin with categories. We should be able to create a category:

# test/categories_test.exs defmodule FirestormData.CategoriesTest do # We'll create a DataCase momentarily use FirestormData.DataCase import FirestormData.Categories alias...
Previous

Implement a forum data model in JavaScript

Next

Building a Forum Elixir GraphQL Backend with Absinthe

login to comment
  1. Comments for Implement a forum data model in Elixir