barrel_att (barrel_docdb v1.1.1)
View SourceAttachment API for barrel_docdb
Provides a higher-level API for attachment operations. Uses barrel_att_store for storage with BlobDB.
Summary
Functions
Check if an attachment exists
Delete an attachment
Delete all attachments for a document
Retrieve an attachment
List all attachment names for a document
Create attachment info from data
Store an attachment
Store an attachment with options (sync, content_type, origin_hlc, expected_digest; see the blob backend).
Validate attachment name
Types
-type att_info() :: #{name := binary(), content_type := binary(), length := non_neg_integer(), digest := binary(), chunked => boolean(), chunk_size => pos_integer(), chunk_count => pos_integer()}.
-type change() :: map().
-type db_name() :: binary().
-type docid() :: binary().
-type revid() :: binary().
-type seq() :: barrel_hlc:timestamp().
-type seq_string() :: binary().
-type view_name() :: binary().
Functions
-spec attachment_exists(barrel_att_store:att_ref(), db_name(), docid(), binary()) -> boolean().
Check if an attachment exists
-spec delete_attachment(barrel_att_store:att_ref(), db_name(), docid(), binary()) -> ok | {error, term()}.
Delete an attachment
-spec delete_doc_attachments(barrel_att_store:att_ref(), db_name(), docid()) -> ok | {error, term()}.
Delete all attachments for a document
-spec get_attachment(barrel_att_store:att_ref(), db_name(), docid(), binary()) -> {ok, binary()} | {error, not_found} | {error, term()}.
Retrieve an attachment
-spec list_attachments(barrel_att_store:att_ref(), db_name(), docid()) -> [binary()].
List all attachment names for a document
Create attachment info from data
-spec put_attachment(barrel_att_store:att_ref(), db_name(), docid(), binary(), binary()) -> {ok, att_info()} | {error, term()}.
Store an attachment
-spec put_attachment(barrel_att_store:att_ref(), db_name(), docid(), binary(), binary(), map()) -> {ok, att_info()} | {ok, ignored} | {error, term()}.
Store an attachment with options (sync, content_type, origin_hlc, expected_digest; see the blob backend).
-spec validate_att_name(binary()) -> ok | {error, invalid_att_name}.
Validate attachment name