Liking cljdoc? Tell your friends :D

com.github.ivarref.clj-paginate


ensure-orderclj

(ensure-order src-vec dst-vec & {:keys [sf df] :or {sf :id df :id}})

Orders dst-vec according to src-vec.

Optional named parameters sf anddfthat defaults to:id`.

(sf source-node) must be equal to some (df dest-node) for one element in dst-vec.

Orders dst-vec according to src-vec.

Optional named parameters `sf and `df`
that defaults to `:id`.

(sf source-node) must be equal to some
(df dest-node) for one element in dst-vec.
sourceraw docstring

get-contextclj

(get-context opts)

Gets the :context from a previous invocation of paginate as stored in :before or :after

Gets the :context from a previous invocation of paginate as stored in :before or :after
sourceraw docstring

paginateclj

(paginate data
          sort-attrs
          f
          opts
          &
          {:keys [context batch?] :or {context {} batch? false}})

Required parameters

data: The data to paginate. Must be either a vector or a map with vectors as values. All vectors must be sorted according to sort-attrs. The actual nodes in the vectors must be maps.

sort-attrs: How the vectors in data is sorted. Should be a single keyword or a vector of keywords.

f: Invoked on each node. Invoked a single time on all nodes if :batch? is true.

opts: A map specifying what data is to be fetched. It must contain either: :first: an int specifying how many nodes to fetch, starting at the beginning of the data.

  Or:
  :last: an int specifying how many nodes to fetch,
  starting at the end of the data.

  The cursor, i.e. where to continue fetching data from
  on subsequent queries, should be given as a string
  in :after if :first is used, or :before if :last is used.

  Opts may also contain `:filter`, which, if present, should be a collection of
  keys to filter the data map on. The filter value will be persisted in
  the cursor string, and will automatically be used on subsequent queries.
  If `:filter` is not specified, no filtering is done.
  Thus the default behaviour is to include everything.

Optional named parameters

:context: User-defined data to store in every cursor. Must be pr-str-able. Defaults to {}. Can be retrieved on subsequent queries using (get-context ...).

:batch?: Set to true if f should be invoked a single time on all nodes, and not once for each node. If this is set to true, f must return the output nodes in the same order as the input nodes. Please see the ensure-order function for a helper function that makes sure the ordering is correct. The default value of :batch? is false.

Return value

The paginated data. Returns a map of {:edges [{:node { ...} :cursor ...} {:node { ...} :cursor ...} ...] :pageInfo {:hasNextPage Boolean :hasPrevPage Boolean :totalCount Integer :startCursor String :endCursor String}}

Required parameters
===================
data: The data to paginate. Must be either a vector or a map with vectors as values.
      All vectors must be sorted according to `sort-attrs`.
      The actual nodes in the vectors must be maps.

sort-attrs: How the vectors in `data` is sorted.
            Should be a single keyword or a vector of keywords.

f: Invoked on each node.
   Invoked a single time on all nodes if :batch? is true.

opts: A map specifying what data is to be fetched.
      It must contain either:
      :first: an int specifying how many nodes to fetch,
      starting at the beginning of the data.

      Or:
      :last: an int specifying how many nodes to fetch,
      starting at the end of the data.

      The cursor, i.e. where to continue fetching data from
      on subsequent queries, should be given as a string
      in :after if :first is used, or :before if :last is used.

      Opts may also contain `:filter`, which, if present, should be a collection of
      keys to filter the data map on. The filter value will be persisted in
      the cursor string, and will automatically be used on subsequent queries.
      If `:filter` is not specified, no filtering is done.
      Thus the default behaviour is to include everything.


Optional named parameters
=========================
:context: User-defined data to store in every cursor. Must be pr-str-able.
          Defaults to {}. Can be retrieved on subsequent queries using
          `(get-context ...)`.

:batch?: Set to true if f should be invoked a single time on all nodes,
         and not once for each node. If this is set to true,
         f must return the output nodes in the same order as the input nodes.
         Please see the `ensure-order` function for a helper function
         that makes sure the ordering is correct.
         The default value of :batch? is false.


Return value
============
The paginated data.
Returns a map of
  {:edges [{:node { ...} :cursor ...}
           {:node { ...} :cursor ...}
            ...]
   :pageInfo {:hasNextPage Boolean
              :hasPrevPage Boolean
              :totalCount Integer
              :startCursor String
              :endCursor String}}
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close