object.ex 382 Bytes
Newer Older
lain's avatar
lain committed
1
2
defmodule Pleroma.Object do
  use Ecto.Schema
3
4
  alias Pleroma.{Repo, Object}
  import Ecto.Query
lain's avatar
lain committed
5
6
7
8
9
10

  schema "objects" do
    field :data, :map

    timestamps()
  end
11
12
13
14
15

  def get_by_ap_id(ap_id) do
    Repo.one(from object in Object,
      where: fragment("? @> ?", object.data, ^%{id: ap_id}))
  end
16
17
18
19

  def context_mapping(context) do
    %Object{data: %{"id" => context}}
  end
lain's avatar
lain committed
20
end