View Source Bonfire.Data.Assort.Ranked (Bonfire v0.9.10-classic-beta.169)

A reusable table to link child or related items and also rank sibling items.

Usage (for global ranking, otherwise you should specify scope):

{:ok, first} = Bonfire.Data.Assort.Ranked.changeset(%{item_id: "01FGTH48ZZD08ADBHQ260KYJHW"}) |> repo().insert
second = Bonfire.Data.Assort.Ranked.changeset(%{item_id: "01FGTH0N3YPBS5MNNAEAEVV54J"}) |> repo().insert

import Ecto.Query
Bonfire.Data.Assort.Ranked |> order_by(:rank) |> repo().all

first |> Bonfire.Data.Assort.Ranked.changeset(%{rank_set: :last}) |> repo().update

Bonfire.Data.Assort.Ranked |> order_by(:rank) |> repo().all

Summary

Functions

Link to this function

changeset(model \\ %Ranked{}, params)

View Source