Resourceful.Collection (Resourceful v0.1.6)
View SourceProvides a common interface for querying and retrieving collections.
Deligated modules designed to interact directly with the underlying data or
data sources must return alls of resources. For instance, when using Ecto,
this module should return alls of structs or maps and not queries that have
not been executed yet.
Data Sources
A data_source can be another from an Ecto schema, to a module that
intteracts with a remote API, to a list as long as there is an underlying
module to support the common interfaces. (For now, that's just Ecto.)
Summary
Functions
Returns a list of resources that may be filtered and sorted depending on on options. Resources will always be paginated.
Checks if data_source contains any resources.
Returns the total number of resources and pages based on page_size in a
data_source.
Returns the total number of resources in a data_source.
Types
@type queryable() :: name() | {name(), name()} | Resourceful.Type.queryable()
@type with_page_info(type) :: {[type], page_info()}
Functions
Returns a list of resources that may be filtered and sorted depending on on options. Resources will always be paginated.
Args:
data_source: See module overview.opts: Keyword list of options
Options:
filter: SeeResourceful.Collection.Filter.call/2page: Pagination options.sort:SeeResourceful.Collection.Sort.call/2
Additionally, see settings for the delegated module as it may take additional options.
@spec all_with_page_info( any(), keyword() ) :: with_page_info()
Checks if data_source contains any resources.
Args:
data_source: See module overview.opts: Keyword list of options
Options: See settings for the delegated module (e.g. Resourceful.Collection.Ecto).
@spec default_page_size() :: integer()
Returns the total number of resources and pages based on page_size in a
data_source.
Args:
data_source: See module overview.opts: Keyword list of options
Options: See settings for the delegated module (e.g. Resourceful.Collection.Ecto).
@spec paginate_with_info( any(), keyword() ) :: with_page_info()
Returns the total number of resources in a data_source.
Args:
data_source: See module overview.opts: Keyword list of options
Options: See settings for the delegated module (e.g. Resourceful.Collection.Ecto).