From 5bddd175f3809d060b3a49030b1d6dd46ade8392 Mon Sep 17 00:00:00 2001 From: Alessandro Tagliapietra Date: Tue, 17 Jan 2023 05:02:40 -0800 Subject: [PATCH] improvement: add nil return type to api get/3, read_one/2 and read_one!/2 (#482) --- lib/ash/api/api.ex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ash/api/api.ex b/lib/ash/api/api.ex index b9a8e990..d83a001e 100644 --- a/lib/ash/api/api.ex +++ b/lib/ash/api/api.ex @@ -487,13 +487,13 @@ defmodule Ash.Api do id_or_filter :: term(), params :: Keyword.t() ) :: - {:ok, Ash.Resource.record()} | {:error, term} + {:ok, Ash.Resource.record()} | {:ok, nil} | {:error, term} @doc """ Run an ash query, raising on more than one result. See `c:read_one/2` for more. """ @callback read_one!(Ash.Query.t() | Ash.Resource.t(), params :: Keyword.t()) :: - Ash.Resource.record() | {Ash.Resource.record(), Ash.Query.t()} | no_return + Ash.Resource.record() | {Ash.Resource.record(), Ash.Query.t()} | nil | no_return @doc """ Run a query on a resource, but fail on more than one result. @@ -504,6 +504,7 @@ defmodule Ash.Api do @callback read_one(Ash.Query.t() | Ash.Resource.t(), params :: Keyword.t()) :: {:ok, Ash.Resource.record()} | {:ok, Ash.Resource.record(), Ash.Query.t()} + | {:ok, nil} | {:error, term} @doc """ Run an ash query. See `c:read/2` for more.