Key-value store records: get, set and delete them.
:ok = ApifyClient.KeyValueStores.put_record(store_id, "state", %{"page" => 2})
{:ok, %{"page" => 2}} = ApifyClient.KeyValueStores.get_record(store_id, "state")
:ok = ApifyClient.KeyValueStores.put_record(store_id, "shot", png, content_type: "image/png")
{:ok, ^png} = ApifyClient.KeyValueStores.get_record(store_id, "shot")Functions take the connection options described in ApifyClient.Client
(:token, :config, ...) next to their own. For everything else about
key-value stores, see ApifyClient.API.KeyValueStores and the modules below it.
Summary
Functions
Deletes a record.
Gets a record's value.
Lists record keys, one page at a time.
Sets a record.
Whether a record exists.
Streams all keys of a store (ApifyClient.Schemas.KeyValueStoreKey structs,
with key and size), fetching them page by page as the stream is consumed.
Functions
@spec delete_record(String.t(), String.t(), keyword()) :: :ok | {:error, ApifyClient.Error.t()}
Deletes a record.
@spec get_record(String.t(), String.t(), keyword()) :: {:ok, term()} | {:error, ApifyClient.Error.t()}
Gets a record's value.
JSON records are decoded (maps with string keys); other records come back as
the raw binary. A missing record is {:error, %ApifyClient.Error{type: :not_found_error}}.
@spec list_keys(String.t(), keyword()) :: {:ok, ApifyClient.Schemas.ListOfKeys.t()} | {:error, ApifyClient.Error.t()}
Lists record keys, one page at a time.
Options
:limit- keys per page (at most 1000):exclusive_start_key- list keys after this one; pass the previous page'snext_exclusive_start_keyto get the next page:prefix- only keys starting with this:collection- only keys in this collection
@spec put_record(String.t(), String.t(), term(), keyword()) :: :ok | {:error, ApifyClient.Error.t()}
Sets a record.
Maps and lists are stored as JSON. Binaries are stored as they are, as
text/plain; charset=utf-8 when valid UTF-8 and application/octet-stream
otherwise, unless :content_type says otherwise.
Options
:content_type- content type of the record
@spec record_exists?(String.t(), String.t(), keyword()) :: {:ok, boolean()} | {:error, ApifyClient.Error.t()}
Whether a record exists.
@spec stream_keys(String.t(), keyword()) :: Enumerable.t()
Streams all keys of a store (ApifyClient.Schemas.KeyValueStoreKey structs,
with key and size), fetching them page by page as the stream is consumed.
Raises ApifyClient.Error if a page can't be fetched.
Options
:prefix- only keys starting with this:collection- only keys in this collection:exclusive_start_key- start after this key:limit- maximum number of keys in the whole stream (default: all):page_size- keys per request (default and maximum: 1000)