Skip to content

Commit

Permalink
Add function clause for accepting struct args
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeyson committed Jul 11, 2023
1 parent c52ed2e commit 6c9d543
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.3.3 (2023.07.11)

* Add index_multiple_documents/1 clause for accepting struct args

## 0.3.2 (2023.07.11)

* Maps struct pk to document's id
Expand Down
7 changes: 6 additions & 1 deletion lib/ex_typesense/document.ex
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,12 @@ defmodule ExTypesense.Document do
{:ok, [%{"success" => true}, %{"success" => true}]}
"""
@doc since: "0.3.0"
@spec update_multiple_documents(map()) :: response()
@spec update_multiple_documents(list(struct()) | map()) :: response()
def update_multiple_documents([struct | _] = list_of_structs) when is_struct(struct) do
collection_name = struct.__struct__.__schema__(:source)
do_index_multiple_documents(collection_name, "update", list_of_structs)
end

def update_multiple_documents(%{collection_name: collection_name, documents: documents} = map)
when is_map(map) do
do_index_multiple_documents(collection_name, "update", documents)
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule ExTypesense.MixProject do
use Mix.Project

@source_url "https://github.com/jaeyson/ex_typesense"
@version "0.3.2"
@version "0.3.3"

def project do
[
Expand Down

0 comments on commit 6c9d543

Please sign in to comment.