+ def create_context(context) do
+ context = context || generate_id("contexts")
+ changeset = Object.context_mapping(context)
+
+ case Repo.insert(changeset) do
+ {:ok, object} ->
+ object
+
+ # This should be solved by an upsert, but it seems ecto
+ # has problems accessing the constraint inside the jsonb.
+ {:error, _} ->
+ Object.get_cached_by_ap_id(context)
+ end
+ end
+