norden.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
Moin! Dies ist die Mastodon-Instanz für Nordlichter, Schnacker und alles dazwischen. Folge dem Leuchtturm.

Administered by:

Server stats:

3.4K
active users

#ecto

1 post1 participant0 posts today
Continued thread

Besides regular schemas with universal foreign keys (Pointable), Needle provides Virtual for schemas that don’t have any fields on their own, and Mixin for storing common fields that can be re-used by multiple Pointables or Virtuals (eg. if you have multiple types that all have a name/description/body, they can share those and optionally the associated changesets and other logic).

#ecto #myElixirStatus #elixir

5/6

Continued thread

But what if you don’t just have posts that can be liked, but also videos, images, polls, etc, each with their own table, but probably do not want to have to add liked_video_id, liked_image_id, ad infinitum?

We needed the flexibility to have a foreign key that can reference any referenceable object. We call our system Needle.

#ecto #myElixirStatus #elixir
4/6

Continued thread

A simple example would be a blogging app, which might have a post table with author field that references the user table.

A social network, by contrast, usually requires a graph of objects, meaning objects need to be able to refer to other objects by their ID without knowing their type.

A simple example would be likes, you might have a likes table with liked_post_id field that references the post table.

#ecto #myElixirStatus #elixir
3/6