Add docs to Elasticsearch.Store

This commit is contained in:
Daniel Berkompas 2018-04-13 14:01:58 -07:00
parent 511cbd0e08
commit 0fdcf997d4
2 changed files with 33 additions and 0 deletions

View File

@ -1,6 +1,7 @@
{
"skip_files": [
"lib/elasticsearch/api/api.ex",
"lib/elasticsearch/storage/store.ex",
"lib/mix/elasticsearch.install.ex",
"test/support/*"
],

View File

@ -1,8 +1,40 @@
defmodule Elasticsearch.Store do
@moduledoc """
A behaviour for fetching data to index. Used by `mix elasticsearch.build`.
"""
@typedoc """
A data source. For example, `Post`, where `Post` is an `Ecto.Schema`.
Each datum returned must implement `Elasticsearch.Document`.
"""
@type source :: any
@typedoc """
Instances of the data source. For example, `%Post{}` structs.
"""
@type data :: any
@typedoc """
The current offset for the query.
"""
@type offset :: integer
@typedoc """
A limit on the number of elements to return.
"""
@type limit :: integer
@doc """
Loads data based on the given source, offset, and limit.
## Example
def load(Post, offset, limit) do
Post
|> offset(^offset)
|> limit(^limit)
|> Repo.all()
end
"""
@callback load(source, offset, limit) :: [data]
end