zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

resolv.ex (1682B)


      1 # Zenflows is designed to implement the Valueflows vocabulary,
      2 # written and maintained by srfsh <info@dyne.org>.
      3 # Copyright (C) 2021-2023 Dyne.org foundation <foundation@dyne.org>.
      4 #
      5 # This program is free software: you can redistribute it and/or modify
      6 # it under the terms of the GNU Affero General Public License as published by
      7 # the Free Software Foundation, either version 3 of the License, or
      8 # (at your option) any later version.
      9 #
     10 # This program is distributed in the hope that it will be useful,
     11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 # GNU Affero General Public License for more details.
     14 #
     15 # You should have received a copy of the GNU Affero General Public License
     16 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
     17 
     18 defmodule Zenflows.VF.SpatialThing.Resolv do
     19 @moduledoc false
     20 # Basically, a fancy name for (geo)location.  :P
     21 
     22 alias Zenflows.GQL.Connection
     23 alias Zenflows.VF.SpatialThing.Domain
     24 
     25 def spatial_thing(params, _) do
     26 	Domain.one(params)
     27 end
     28 
     29 def spatial_things(params, _) do
     30 	with {:ok, page} <- Connection.parse(params),
     31 			{:ok, schemas} <- Domain.all(page) do
     32 		{:ok, Connection.from_list(schemas, page)}
     33 	end
     34 end
     35 
     36 def create_spatial_thing(%{spatial_thing: params}, _) do
     37 	with {:ok, spt_thg} <- Domain.create(params) do
     38 		{:ok, %{spatial_thing: spt_thg}}
     39 	end
     40 end
     41 
     42 def update_spatial_thing(%{spatial_thing: %{id: id} = params}, _) do
     43 	with {:ok, spt_thg} <- Domain.update(id, params) do
     44 		{:ok, %{spatial_thing: spt_thg}}
     45 	end
     46 end
     47 
     48 def delete_spatial_thing(%{id: id}, _) do
     49 	with {:ok, _} <- Domain.delete(id) do
     50 		{:ok, true}
     51 	end
     52 end
     53 end